
10 Apr
2006
10 Apr
'06
12:25 p.m.
On Mon, Apr 10, 2006 at 03:54:09PM +0100, Chris Kuklewicz wrote:
If the goal is speed, then this definition is running over 10% faster with ghc -O2 on my powerbook for (sum $ map length $ inits [1..10000])
inits' = helper id where helper f [] = (f []):[] helper f (x:xs) = (f []):helper (f.(x:)) xs
I rather like inits = map ($ []) . scanl (.) id . map (:) but this is also competitive: inits = map reverse . scanl (flip (:)) []