I would solve it by comparing the first index of the first list and adding 2 to the index. But I do not know how to check for indexes in prolog. Also, I would create a counter that ignores what is in the list when the counter is an odd number (if we start to count from 0). Can you help me? Example: everyOther([1,2,3,4,5],[1,3,5]) is true, but everyOther([1,2,3,4,5],[1,2,3]) is not.

# Best How To :

Here is a simple **logically pure** implementation of `list_oddies/2`

:

The relations `list_oddies/2`

and `skipHead_oddies/2`

are defined mutually recursive. Both use first-argument indexing to avoid the creation of useless choicepoints.

```
list_oddies([],[]).
list_oddies([X|Xs],[X|Ys]) :-
skipHead_oddies(Xs,Ys).
skipHead_oddies([],[]).
skipHead_oddies([_|Xs],Ys) :-
list_oddies(Xs,Ys).
```

Here are the queries @WouterBeek gave in his answer. All queries succeed deterministically.

```
?- list_oddies([],Xs).
Xs = [].
?- list_oddies([a],Xs).
Xs = [a].
?- list_oddies([a,b],Xs).
Xs = [a].
?- list_oddies([a,b,c],Xs).
Xs = [a,c].
?- list_oddies([a,b,c,d],Xs).
Xs = [a,c].
?- list_oddies([a,b,c,d,e],Xs).
Xs = [a,c,e].
?- list_oddies([a,b,c,d,e,f],Xs).
Xs = [a,c,e].
?- list_oddies([a,b,c,d,e,f,g],Xs).
Xs = [a,c,e,g].
```

Note that, with pure code, even the *most general query* gives *reasonable answers*:

```
?- list_oddies(Xs,Ys).
Xs = [], Ys = [] ;
Xs = [_A], Ys = [_A] ;
Xs = [_A,_B], Ys = [_A] ;
Xs = [_A,_B,_C], Ys = [_A,_C] ;
Xs = [_A,_B,_C,_D], Ys = [_A,_C] ;
Xs = [_A,_B,_C,_D,_E], Ys = [_A,_C,_E] ;
Xs = [_A,_B,_C,_D,_E,_F], Ys = [_A,_C,_E] ;
Xs = [_A,_B,_C,_D,_E,_F,_G], Ys = [_A,_C,_E,_G] ;
Xs = [_A,_B,_C,_D,_E,_F,_G,_H], Ys = [_A,_C,_E,_G] ...
```