
11 Sep
2012
11 Sep
'12
2:43 p.m.
On Tue, 11 Sep 2012, Niklas Hambüchen wrote:
I would like to propose adding a the functions scanl' and scanl1' to Data.List.
The presence and regular use of foldl' and foldl1' suggests that corresponding scan functions should be available.
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))
What do you think?
I don't know whether this "scanl'" is of much use. "foldl'" is required because we can access its accumulator only after "foldl'" finished. But in "scanl'" you can and usually should access the interim accumulator values that are contained in the result list.