import Prelude hiding (last,unzip,take) -- The last element of a list: last :: [a] -> a last [x] = x last (x:xs@(_:_)) = last xs -- Unzip a list of pairs into two lists. unzip :: [(a,b)] -> ([a],[b]) unzip [] = ([],[]) unzip ((x,y):ps) = case unzip ps of (xs,ys) -> (x:xs, y:ys) fac :: Int -> Int fac n | n==0 = 1 | n>0 = n * fac (n-1) -- Returns the first n elements of a list take :: Int -> [a] -> [a] take n xs | n == 0 = [] | otherwise = case xs of [] -> [] (x:xs) -> x : take (n-1) xs