Hello dear Community,
I want to get all the elements that are at an even position in the list. This is for the implementation of the game of darts.
eg. [((3,20),(1,19),(2,17)),((3,20),(2,12),(2,19))] -> [((3,20),(1,19),(2,17))]
So far I have tried:
positioneven n [] = []
positioneven n (x:xs) = if even n
then (x: positioneven n+1 xs)
else positioneven n+1 xs
But that, of course, did not work. I would be very happy if someone could offer me a better solution.
Thank! Nazar
source
share