The standard definition of inits:
inits [] = [[]]
inits (x:xs) = [[]] ++ map (x:) (inits xs)
is unnecessarily strict, evaluating its argument
before yielding the initial [] of the result.
An improved version is:
inits l = [] : case l of [] -> []
(x:xs) -> map (x:) inits xs
This allows one to define for instance
nats = map length (inits nats)
which loops for the standard definition.
regards,
-John
_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell