summaryrefslogtreecommitdiff
path: root/11-20/20.hs
blob: c6a3ba8e4c9a07d668b04040a9cb05b4edb685eb (plain) (blame)
1
2
3
4
5
6
removeAt :: Int -> [a] -> (Maybe a, [a])

removeAt k (x:xs)
  | k > 1 = let (a, b) = removeAt (k - 1) xs in (a, x:b)
  | k == 1 = (Just x, xs)
removeAt _ l = (Nothing, l)