Proposal: Strict scanl, scanl1 and mapAccumL

Henning Thielemann lemming at henning-thielemann.de
Mon Nov 12 10:41:38 CET 2012


On Mon, 12 Nov 2012, Bas van Dijk wrote:

> Data.List exports strict versions of foldl an foldl1. I think it
> should also export these strict versions of scanl, scanl1 and
> mapAccumL:
>
> scanl' :: (a -> b -> a) -> a -> [b] -> [a]
> scanl' f q ls =  q : (case ls of
>                        []   -> []
>                        x:xs -> let q' = f q x
>                                in q' `seq` scanl f q' xs)
>
> scanl1' :: (a -> a -> a) -> [a] -> [a]
> scanl1' f (x:xs) =  scanl' f x xs
> scanl1' _ []     =  []
>
> mapAccumL' :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])
> mapAccumL' _ s []     =  (s, [])
> mapAccumL' f s (x:xs) =  (s'',y:ys)
>    where
>      (s', y ) = f s x
>      (s'',ys) = s' `seq` mapAccumL' f s' xs
>
> Is there a good reason they're not included?
>
> Discussion deadline: 2 weeks (till Monday 26 November).

There was already a discussion some weeks ago:

http://www.haskell.org/pipermail/libraries/2012-September/018434.html



More information about the Libraries mailing list