:: (a -> a) -> a -> [a] -package:wraxml

iterate f x returns an infinite list of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]

Laziness

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 1 $ iterate undefined 42
[42]

Examples

>>> take 10 $ iterate not True
[True,False,True,False,True,False,True,False,True,False]
>>> take 10 $ iterate (+3) 42
[42,45,48,51,54,57,60,63,66,69]
iterate id == repeat:
>>> take 10 $ iterate id 1
[1,1,1,1,1,1,1,1,1,1]
iterate' is the strict version of iterate. It forces the result of each application of the function to weak head normal form (WHNF) before proceeding.
>>> take 1 $ iterate' undefined 42
*** Exception: Prelude.undefined
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 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.
iterate' is the strict version of iterate. It forces the result of each application of the function to weak head normal form (WHNF) before proceeding.
A challenge from a Clojurist on Hacker News (https://news.ycombinator.com/item?id=23939350)
> cl_map (uncurry (+)) ([1,2,3], [4,5,6])
[5,7,9]

> cl_map (+3) [1,2,3]
[4,5,6]

> let max3 (x, y, z) = x `max` y `max` z
> cl_map max3 ([1,20], [3,4], [5,6])
[5,20]
Computes the orbit of a endomorphism... in a very brute force manner. Exists just for the below property.
length . orbit nudgeBS . S.pack . replicate 0 == (256^)