[Haskell-cafe] When folding is there a way to pick out the last
point being processed?
thomas.dubuisson at gmail.com
Thu Jun 11 22:41:11 EDT 2009
Something like the belo 'foldL_last'? You could probably do it
cleaner, but I don't think there is a library function that would help
any more than foldl.
foldL_last :: (a -> b -> a) -> a -> [b] -> (Maybe b, a)
foldL_last f x xs = foldl (\(_,a) b -> (Just b, f a b)) (Nothing, x) xs
On Thu, Jun 11, 2009 at 6:47 PM, Casey Hawthorne<caseyh at istar.ca> wrote:
> When folding is there a way to pick out the last point being
> The first point can easily be picked out with (x:xs) but last xs
> crawls down the list.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe