module DropEnd where dropEnd :: Int -> [a] -> [a] dropEnd n = snd . foldr acc (n, []) where acc x (m, xs) | m <= 0 = (0 , x:xs) | otherwise = (m - 1, xs)