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
- Re: Zipping two sequences together with only cons, empt... Lennart Augustsson
- Re: Zipping two sequences together with only cons, empt... Kevin Atkinson
- Re: Zipping two sequences together with only cons, empt... Lennart Augustsson
- Re: Zipping two sequences together with only cons, empt... Kevin Atkinson
- Re: Zipping two sequences together with only cons, empt... Koen Claessen
- Re: Zipping two sequences together with only cons, empt... Torsten Grust
- Re: Zipping two sequences together with only cons, empt... Peter Hancock
- Re: Zipping two sequences together with only cons, empt... Laszlo Nemeth
- Re: Zipping two sequences together with only cons, empt... Erik Meijer
- Re: Zipping two sequences together with only cons, empt... Laszlo Nemeth
- Re: Zipping two sequences together with only cons, empt... Lennart Augustsson
- Re: Zipping two sequences together with only cons, empt... Lennart Augustsson