Domanda

i must assert in SWI this kind of CLP(FD) rules:

    asserta(schedule(A,B) :-  V = [S0,S1,S2],V ins 0..sup).

but i get this error:

    ERROR: Syntax error: Operator expected
    ERROR: asserta(schedule(A,B) :-  V = [S0,S1,S2],V 
    ERROR: ** here **
    ERROR: ins 0..sup) . 

why? thank you!

È stato utile?

Soluzione

There are two errors here:

You need to have CLP(FD) loaded at the time when reading the text. So there needs to be a use_module(library(clpfd)) either as a directive like in a line

:- use_module(library(clpfd)).

or entered as a goal on the toplevel. This is necessary because you are using (ins)/2 in operator form.

The other problem is the missing parentheses. It should rather read:

 ..., asserta( ( schedule(A,B) :- V = [_,_,_], V ins 0..sup ) ), ...

As an aside, I do not think that asserting such a rule makes much sense. Dynamic databases are rarely used together with asserting rules as this one.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top