Skip to content

Add scanl'

The presence of foldl' and foldl1' suggests the addition of scanl' (and scanl1') to Data.List:

scanl'                   :: (a -> b -> a) -> a -> [b] -> [a]
scanl' f q ls            =  q `seq` (q : (case ls of
                                     []   -> []
                                     x:xs -> scanl' f (f q x) xs))

This would finally sort out the infamous (last . scanl) problem.

Trac metadata
Trac field Value
Version 7.7
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC mail@nh2.me
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information