0
votes

I'm trying to write a prediate that returns every third letter of a list. This is my code so far:

third([],X):-X=[].
third([_],X):-X=[].
third([_,_],X):-X=[].
third([_,_,C|T],X):- third[T,Z], X=[C|Z].

I get the "operator expected" error on the last line.

Does anyone know why?

1

1 Answers

2
votes

Shouldn't third[T,Z] really be third(T,Z)?