user2960510
user2960510

Reputation: 1243

PROLOG - Syntax error: Operator expected when using not (..)

I'm want to write prolog code to give me L3 that's contains L1 with out the parameters of L2 (L3 = L1\L2).

and in this code i got this problem :

Syntax error: Operator expected

for the last line of

contains(_,[]) .
contains(L1,[X|TL]) :- member( X, L1) , contains(L1,TL).
minus(L1,L2,L3) :- contains(L3,L1) , not ( contains(L3,L2) ).

thanks.

Upvotes: 0

Views: 444

Answers (1)

Paulo Moura
Paulo Moura

Reputation: 18663

not is (usually) not defined as an operator. You should write instead not( contains(L3,L2) ) or, better yet, use the ISO Prolog standard (\+)/1 negation control construct and write \+ ( contains(L3,L2) ).

Upvotes: 3

Related Questions