fun square x = x * x; fun fact x = if x=0 then 1 else x * fact (x-1); fun sum [] = 0 | sum (x::xs) = x + sum xs; fun length [] = 0 | length (x::xs) = 1 + length xs; fun append [] ys = ys | append (x::xs) ys = x :: append xs ys; fun map f [] = [] | map f (x::xs) = f x :: map f xs;