iterate -package:Stream

iterate f x returns an infinite list of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
Note that iterate is lazy, potentially leading to thunk build-up if the consumer doesn't force each iterate. See iterate' for a strict variant of this function.
>>> take 10 $ iterate not True
[True,False,True,False...

>>> take 10 $ iterate (+3) 42
[42,45,48,51,54,57,60,63...
iterate f x produces the infinite sequence of repeated applications of f to x.
iterate f x = x :| [f x, f (f x), ..]
iterate f x returns an infinite ByteString of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
iterate f x returns an infinite ByteString of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
iterate f x returns an infinite Text of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
Produces an infinite stream of repeated applications of f to x. Subject to fusion
I think this makes only sense in a lazy monad like Trans.State.Lazy or IO.Lazy.
Iterate a pure function from a seed value, streaming the results forever
iterate f x returns an infinite list of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
Note that iterate is lazy, potentially leading to thunk build-up if the consumer doesn't force each iterate. See iterate' for a strict variant of this function.
An infinite list of repeated calls of the function to args
iterate f x returns an infinite ByteStream of repeated applications -- of f to x:
iterate f x == [x, f x, f (f x), ...]
>>> R.stdout $ R.take 50 $ R.iterate succ 39
()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY

>>> Q.putStrLn $ Q.take 50 $ Q.iterate succ '\''
()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY
iterate f x returns an infinite ByteStream of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
>>> iterate f x = x `Stream.cons` iterate f x
Generate an infinite stream with x as the first element and each successive element derived by applying the function f on the previous element.
>>> Stream.toList $ Stream.take 5 $ Stream.iterate (+1) 1
[1,2,3,4,5]
Create a sorted list by repeatedly applying the same function to an element, until the image by that function is stricly less than its argument. In other words:
iterate f x = [x, f x, f (f x), ... ]
With the list ending whenever f (f (... (f (f x)) ...)) < f (... (f (f x)) ...). If this never happens, the list will be infinite. By definition:
iterate f = unfoldr (\x -> Just (x, f x))
>>> iterate f x = x `Stream.cons` iterate f x
Generate an infinite stream with x as the first element and each successive element derived by applying the function f on the previous element.
>>> Stream.fold Fold.toList $ Stream.take 5 $ Stream.iterate (+1) 1
[1,2,3,4,5]
Keep running the same consumer over and over again on the input, feeding the output of the previous run to the next. Internal