// (* Richard Bird: Introduction to functional programming using Haskell, Section 7.2 *) module RevFoldl; def Acc foldlP(f)(Acc z, List xs) = case xs { Nil => z; Cons(x,xsP) => foldlP(f(z,x), xsP); }; def List prefix(List xs, A x) = Cons(x,xs); def List rev(List l) = foldlP(prefix)(Nil, l); def List start(List l) = rev(l); { }