fun reverse xs = foldr (fn (x,xs') => xs' @ [x]) [] xs fun forall p xs = foldr (fn (x,b) => b andalso p x) true xs