Hello .
I am writng a code that drop every n-th element from a list:
for example
dropevery [0,1,2,3,4,5,6,7,8,9] 3
->[0,1,3,4,6,7,9] this list show up.2,5,8 were droped from the list because those numbers are every 3rd element in the list.
my code is like
dropevery :: [a] → Int → [a]
–base case
dropevery [] = []
dropevery (x:xs) = x: (dropevery (remove x xs))
where
remove :: Int → [Int] → [Int]
remove x [] = []
remove x (y:ys)
| x==y = remove x ys
|otherwise = y:(remove x ys)
functioncall = dropevery[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]3
main = putStrLn (show functioncall)
I want drop 3,6,9,12,15 from the list, but I got some error.
Could anyone tell and teach me what is/are wrong with my code and fix it/them for me?