{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
module Solutions.P20 (removeAt) where
removeAt :: Int -> [a] -> (a,[a])
removeAt :: forall a. Int -> [a] -> (a, [a])
removeAt Int
n [a]
xs = (a
e, [a]
front [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a]
back)
where front :: [a]
front = Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [a]
xs
(a
e : [a]
back) = Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [a]
xs