Lennart Augustsson wrote: > > Kevin Atkinson wrote: > > > Lennart Augustsson wrote: > > > > > No, it will not be as efficient. foldr is not the right primitive for making > > > functions on lists. You want the more general > > > recurse :: (a -> c a -> b -> b) -> b -> c a -> b > > > > Could you give me some refrence on how that function is used as this is > > the first time I herd of it. > > Well, I just made up the name since it's not a standard function (it should be :-). > It is useful for functions doing primitive recursion. > > > What exactly does it do? What would its defination for a list be. > > How would you define a foldl, foldr, foldl1, foldr1, zip, etc.. with it. > > 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. -- Kevin Atkinson [EMAIL PROTECTED] http://metalab.unc.edu/kevina/
- Zipping two sequences together with only cons, empty, f... Kevin Atkinson
- Re: Zipping two sequences together with only cons,... Laszlo Nemeth
- Re: Zipping two sequences together with only cons,... Kevin Atkinson
- Re: Zipping two sequences together with only cons,... Lennart Augustsson
- Re: Zipping two sequences together with only cons,... Kevin Atkinson
- Re: Zipping two sequences together with only cons,... Valery Trifonov
- Re: Zipping two sequences together with only cons,... Kevin Atkinson
- Re: Zipping two sequences together with only cons,... Lennart Augustsson
- Re: Zipping two sequences together with only cons,... Kevin Atkinson
- Re: Zipping two sequences together with only cons,... Lennart Augustsson
- Re: Zipping two sequences together with only cons,... Kevin Atkinson
- Re: Zipping two sequences together with only cons,... Koen Claessen
- Re: Zipping two sequences together with only cons,... Torsten Grust
- Re: Zipping two sequences together with only cons,... Peter Hancock
- Re: Zipping two sequences together with only cons,... Laszlo Nemeth
- Re: Zipping two sequences together with only cons,... Erik Meijer
- Re: Zipping two sequences together with only cons,... Laszlo Nemeth
- Re: Zipping two sequences together with only cons,... Lennart Augustsson
- Re: Zipping two sequences together with only cons,... Lennart Augustsson