module ListMapRev2; // The usual list rev_map function. def List rmap(f)(List l, List acc) = case l { Nil => acc; Cons(x,xs) => rmap(xs, Cons(f(x),acc)); }; def List map_rev(f)(List l) = rmal(l,Nil); def List rmap1(f1,f2)(List l, List acc) = case l { Nil => acc; Cons(x,xs) => rmap2(f1,f2)(xs, Cons(f1(x), acc)); }; def List rmap2(f1,f2)(List l, List acc) = case l { Nil => acc; Cons(x,xs) => rmap1(f1,f2)(xs, Cons(f2(x),acc)); }; // Iteratively apply two functional arguments. def List map_rev2(f1, f2)(List l) = rmap1(l, Nil); def List start(f1, f2)(List l) = map_rev(f1,f2)(l); { }