[Haskell-beginners] iterated function value sequence

Bob Ippolito bob at redivi.com
Fri Apr 4 20:35:50 UTC 2014


There's a function named iterate in Prelude:

λ> :info iterate
iterate :: (a -> a) -> a -> [a] -- Defined in `GHC.List'
λ> take 8 (iterate (\x -> 2 * x + 1) 0)
[0,1,3,7,15,31,63,127]



On Fri, Apr 4, 2014 at 1:25 PM, John M. Dlugosz <ngnr63q02 at sneakemail.com>wrote:

> What's a good way to produce an iterated function value sequence?  That
> is, f(x), f(f(x)), f(f(f(x))), etc.
>
> ref: https://www.youtube.com/watch?v=09JslnY7W_k
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140404/d2e1f65d/attachment-0001.html>


More information about the Beginners mailing list