99-haskell-problems/Problems 11-20/problem_17.hs

5 lines
148 B
Haskell

split :: [a] -> Int -> ([a], [a])
split x 0 = ([], x)
split (hd : tl) n = (hd : next_hd, next_tl)
where
(next_hd, next_tl) = split tl (n - 1)