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

5 lines
142 B
Haskell
Raw Permalink Normal View History

2024-05-24 18:50:16 -05:00
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)