Proposal: Add a strictly accumulating scanl' to Data.List
David Feuer
david.feuer at gmail.com
Thu Jul 24 20:55:59 UTC 2014
Joachim Breitner wrote, in
https://ghc.haskell.org/trac/ghc/ticket/9345#comment:6, a strictly
accumulating version of scanl, to be named scanl'. I was initially
concerned about its safety for fusion, but am now convinced of its
correctness and believe it should be added to Data.List.
scanl' :: (b -> a -> b) -> b -> [a] -> [b]
scanl' f a bs = build $ \c n ->
a `seq` a `c`
foldr (\b g x -> (let b' = f x b in b' `seq` (b' `c` g b')))
(\b -> b `seq` n)
bs
a
More information about the Libraries
mailing list