iterate -is:exact -package:storablevector package:utility-ht
I think this makes only sense in a lazy monad like
Trans.State.Lazy or IO.Lazy.
parameter order equal to that of
nest
Deprecated: use M.iterateLimit
For an associative operation
op this computes
iterateAssociative op a = iterate (op a) a but it is even
faster than
map (powerAssociative op a a) [0..] since it
shares temporary results.
The idea is: From the list
map (powerAssociative op a a)
[0,(2*n)..] we compute the list
map (powerAssociative op a a)
[0,n..], and iterate that until
n==1.
\x -> equating (take 1000) (List.iterate (x+) x) (iterateAssociative (+) (x::Integer))
This is equal to
iterateAssociative. The idea is the following:
The list we search is the fixpoint of the function: "Square all
elements of the list, then spread it and fill the holes with
successive numbers of their left neighbour." This also preserves log n
applications per value. However it has a space leak, because for the
value with index
n all elements starting at
div n 2
must be kept.
\x -> equating (take 1000) (List.iterate (x+) x) (iterateLeaky (+) (x::Integer))