<div dir="auto">I think this discussion would be more appropriate to the libraries list.</div><div class="gmail_extra"><br><div class="gmail_quote">On Nov 9, 2017 11:05 AM, "Geraint Jones" <<a href="mailto:Geraint.Jones@wolfson.ox.ac.uk">Geraint.Jones@wolfson.ox.ac.uk</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There are two things you might think of when you think of scanr;<br>
or rather, there are two things I think of: a specification<br>
<br>
scanr f e = map (foldr f e) . tails<br>
<br>
and an implementation<br>
<br>
scanr f e = foldr g [e] where g x yss@(ys:_) = f x ys : yss<br>
<br>
Of course these two differ, because the one I called an implemntation<br>
is strict wheras the specification isn't.<br>
<br>
I wouldn't mind, but scanl goes to the trouble of not being strict,<br>
as does Data.List.tails, which means inter alia that scanr (:) [] is<br>
not an implementation of Data.List.tails as you might have expected.<br>
(Well, as I did.)<br>
<br>
<br>
In the context of<br>
<br>
> arb = error "not used in demo"<br>
> bot = error "bottom"<br>
<br>
you get<br>
<br>
*Main> (null . map (foldr arb arb) . Data.List.tails) bot<br>
False<br>
*Main> (null . scanr arb arb) bot<br>
*** Exception: bottom<br>
*Main> (null . scanl arb arb) bot<br>
False<br>
______________________________<wbr>_________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.<wbr>org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/glasgow-<wbr>haskell-users</a><br>
</blockquote></div></div>