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

4 lines
142 B
Haskell

slice :: [a] -> Int -> Int -> [a]
slice [] _ _ = error "Invalid indices"
slice l 1 n = take n l
slice (_ : tl) m n = slice tl (m - 1) (n - 1)