I don&#39;t really care if the function is called chop or not.<div>But in many cases it is used to chop a list into smaller pieces.<br><br><div class="gmail_quote">On Tue, Dec 14, 2010 at 12:00 AM, wren ng thornton <span dir="ltr">&lt;<a href="mailto:wren@freegeek.org">wren@freegeek.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 12/13/10 12:17 PM, Lennart Augustsson wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I would like to propose the following function for inclusion in Data.List<br>
<br>
chop :: ([a] -&gt; (b, [a])) -&gt;  [a] -&gt;  [b]<br>
chop _ [] = []<br>
chop f as = b : chop f as&#39;<br>
   where (b, as&#39;) = f as<br>
<br>
It&#39;s commonly occuring recursion pattern.  Typically chop is called<br>
with some function that will consume an initial prefix of the list<br>
and produce a value and the rest of the list.<br>
<br>
The function is clearly related to unfoldr, but I find it more<br>
convenient to use in a lot of cases.<br>
</blockquote>
<br></div>
It&#39;s also deeply related to iteratees (for the obvious enumerator of a list). The major difference is that iteratees enforce that the consuming function must return a tail of the input stream, whereas this function doesn&#39;t require that at all (for both good and ill).<br>

<br>
The name &quot;chop&quot; seems a bit strange to me, but other than that it&#39;s a nice function.<br><font color="#888888">
<br>
-- <br>
Live well,<br>
~wren<br>
<br>
_______________________________________________<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>
</font></blockquote></div><br></div>