Proposal: Add chop function to Data.List
lennart at augustsson.net
Tue Dec 14 16:38:11 CET 2010
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.
On Tue, Dec 14, 2010 at 10:40 AM, Stefan Holdermans <
stefan at vectorfabrics.com> wrote:
> >> I would like to propose the following function for inclusion in
> >> chop :: (a -> (b, [a]) -> [a] -> [b]
> >> chop _  = 
> >> chop f as = b : chop f as'
> >> where (b, as') = f as
> > Is the difference between 'unfoldr' and 'chop' just the Maybe result type
> of f?
> chop f = unfoldr g
> g  = Nothing
> g as = Just (f as)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries