<p dir="ltr">+1 for adding a strict version of iterate. I have to roll my own all the time. Regarding this particular implementation, I am neither for nor against, because I haven't thought it through yet.</p>
<div class="gmail_quote">On Jul 29, 2014 8:48 PM, "David Feuer" <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">I think most if not all applications of iterate would prefer to accumulate strictly—iterating a constant function is not very useful and the spine of the result of iterate is always the same. Unlike unfoldr, which has enough strictness built in to allow its caller to decide whether to accumulate strictly, iterate is entirely lazy. I therefore propose:</p>


<p dir="ltr">iterate' :: (a -> a) -> a -> [a]<br>
iterate' f b = unfoldr go b<br>
  where<br>
    go x = x `seq` Just (x, f x)</p>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></blockquote></div>