inits

Christian Maeder maeder at tzi.de
Mon Apr 10 12:16:17 EDT 2006


Chris Kuklewicz wrote:
> inits' = helper id
>     where helper f [] = (f []):[]
>           helper f (x:xs) = (f []):helper (f.(x:)) xs

This one looks nice, maybe the helper should be changed to allow "head $ 
inits' undefined":

             helper f xs = f [] : case xs of
                        [] -> []
                        x : r -> helper (f . (x :)) r

C.


More information about the Libraries mailing list