<div dir="ltr">Likewise +1 for the idea, but no particular preference for implementation.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 30, 2014 at 8:39 AM, Jake McArthur <span dir="ltr"><<a href="mailto:jake.mcarthur@gmail.com" target="_blank">jake.mcarthur@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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"><div><div class="h5">On Jul 29, 2014 8:48 PM, "David Feuer" <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>> wrote:<br type="attribution"></div></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<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></div></div>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">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>
<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><br></div>