The Haskell type signatures are take :: Int -> [a] -> [a] and drop :: Int -> [a] -> [a]. These definitions also handle nonpositive counts as the Prelude does:
take n _ | n <= 0 = []
take _ [] = []
take n (x:xs) = x : take (n-1) xs

drop n xs | n <= 0 = xs
drop _ [] = []
drop n (_:xs) = drop (n-1) xs
The wildcard in the first equation matters under lazy evaluation: take 0 undefined yields [] without inspecting its list argument. The remainder of this question uses nonnegative counts.[ref]

Articles by others on the same topic (0)

There are currently no matching articles.