views:

248

answers:

1

Hi,

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  A: 

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

Anders Lindahl