99-haskell-problems/Problems 1-10/problem_02.hs

4 lines
125 B
Haskell

myButLast :: [a] -> a
myButLast [] = error "List length less than 2"
myButLast [a, _] = a
myButLast (hd : tl) = myButLast tl