-- 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 | xs == _ ++ [e] = e where e free -- The last element of a list with functional patterns: last' (_ ++ [e]) = e perm [] = [] perm (xs ++ [x] ++ ys) = x : perm (xs ++ ys)