-- The factorial function: fac :: Int -> Int fac n = if n==0 then 1 else n * fac (n - 1) -- The last element of a list: last xs | _ ++ [x] == xs = x where x free -- The last element of a list with a functional pattern: last' (_ ++ [x]) = x perm [] = [] perm (xs ++ [x] ++ ys) = x : perm (xs ++ ys)