I am writing function that take a list of Int, a list of general type a and remove all elements that have index in the list of Int.
For example: removeEl [1,3,4] [1,2,3,4,5,6] return [1,3,6]
or removeEl [1,2] "Firefox" return "Fefox"
Here is my attempt:
removeEl :: [Int] -> [a] -> [a]
removeEl [] xs = []
removeEl ns [] = []
removeEl (n:ns) (x:xs) | n == 0 = removeEl ns xs
| n > 0 = x:removeEl (n-1) xs
I realize (n-1) is an Int, not [Int] so it fail. Do I need to write an auxiliary function to use?
n > 0case, you would also need to decrease the following indices (not just the first).