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

4 lines
121 B
Haskell

insertAt :: a -> [a] -> Int -> [a]
insertAt x ls n = left ++ [x] ++ right
where
(left, right) = splitAt (n - 1) ls