[Haskell-cafe] When folding is there a way to pick out the last point being processed?

Claude Heiland-Allen claudiusmaximus at goto10.org
Thu Jun 11 22:57:45 EDT 2009


Casey Hawthorne wrote:
> When folding is there a way to pick out the last point being
> processed?

I came up with these:

safeHead = foldr (const . Just) Nothing
safeLast = foldr (flip mplus . Just) Nothing


Claude
-- 
http://claudiusmaximus.goto10.org


More information about the Haskell-Cafe mailing list