playground/haskell/99-problems/1.hs

8 lines
146 B
Haskell

myLast :: [a] -> a
-- https://wiki.haskell.org/99_questions/Solutions/1
myLast [] = error "List empty"
myLast [x] = x
myLast (x:xs) = myLast xs