[Haskell-cafe] unfoldr with a little extra
David Feuer
david.feuer at gmail.com
Sat Aug 2 19:56:01 UTC 2014
Edward Kmett's NonEmpty module has a version of unfoldr (there just called
unfoldr) for non-empty lists that seems also to be useful when applied to
regular lists:
unfoldr1::(b -> (a, Maybe b)) -> b -> [a]
unfoldr1 f b= go b
where
go q = case f q of
(a,may_b) -> a : maybe [] go may_b
My question is whether it is possible to write this function using the
usual unfoldr. I have the feeling there might be some way, but I just can't
see it.
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140802/7c194860/attachment.html>
More information about the Haskell-Cafe
mailing list