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

5 lines
125 B
Haskell
Raw Normal View History

2024-05-24 17:06:42 -05:00
myButLast :: [a] -> a
myButLast [] = error "List length less than 2"
myButLast [a, _] = a
myButLast (hd : tl) = myButLast tl