Yes, chop can be easily written in terms of unfoldr. But the chop function fits better with other existing list functions, like I tried to illustrate with my examples.<div><br></div><div> -- Lennart<br><br><div class="gmail_quote">
On Tue, Dec 14, 2010 at 10:40 AM, Stefan Holdermans <span dir="ltr"><<a href="mailto:stefan@vectorfabrics.com">stefan@vectorfabrics.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Henning,<br>
<div class="im"><br>
>> I would like to propose the following function for inclusion in Data.List<br>
>> chop :: (a -> (b, [a]) -> [a] -> [b]<br>
>> chop _ [] = []<br>
>> chop f as = b : chop f as'<br>
>> where (b, as') = f as<br>
<br>
<br>
</div><div class="im">> Is the difference between 'unfoldr' and 'chop' just the Maybe result type of f?<br>
<br>
<br>
</div>Yes.<br>
<br>
chop f = unfoldr g<br>
where<br>
g [] = Nothing<br>
g as = Just (f as)<br>
<br>
Cheers,<br>
<font color="#888888"><br>
Stefan</font></blockquote></div><br></div>