99-haskell-problems/Problems 21-28/problem_21.hs

5 lines
121 B
Haskell
Raw Normal View History

2024-05-25 19:28:16 -05:00
insertAt :: a -> [a] -> Int -> [a]
insertAt x ls n = left ++ [x] ++ right
where
(left, right) = splitAt (n - 1) ls