on master help sign in
Fix iterate with optimal sharing
commit16d8753640f73831e84a2b5610e6d3505c128875 authorMax New <maxsnew@gmail.com> dateMon 9 Dec 2013, 17:21 (13 years ago) parent12d3cc5
1 file changed+2−3
libraries/Lazy/Stream.elm+2−3
libraries/Lazy/Stream.elm+2−3
@@ -50,9 +50,8 @@ cons' = S . lazy
5050 iterate f x = S.cons x (S.cons (f x) (S.cons (f (f x)) ...))
5151-}
5252iterate : (a -> a) -> a -> Stream a
53−iterate f x = let go = cons' <| \() ->
54− (x, map f go)
55− in go
53+iterate f x = cons' <| \() ->
54+ (x, iterate f (f x))
5655
5756{-| Create an infinite Stream of xs. -}
5857repeat : a -> Stream a