Kevin Atkinson wrote:

> > I think the type should (almost) explain what it does :), let me exemplfy for lists
> > recurse c n [] = n
> > recurse c n (x:xs) = c x xs (recurse c n xs)
> >
> > So it's like foldr, except that the cons function gets the tail of the list,
> > not just the head.  With it you can define an efficient tail function.
>
> Ok so how would you define, a foldl, foldr, foldl1, foldr1, and zip
> using it?
>
> I remember seeing it before and I could not figure out how to define a
> foldl using it.

Since you can define foldr from recurse you can do foldl (since foldl can
be done from foldr). You can do zip as shown earlier, but the caseList
function can me simplified a lot using recurse (i.e. you don't need the
recrsion :-).

    -- Lennart




Reply via email to