views:

36

answers:

1

I have defined a prolog file with the following code:

divisible(X, Y) :-
    X mod Y =:= 0.

divisibleBy(X, Y) :-
    divisible(X, Y).

op(35,xfx,divisibleBy).

Prolog is complaining that

'$record_clause'/2: No permission to modify static_procedure `op/3'

What am I doing wrong? I want to define an divisibleBy operator that will allow me to write code like the following:

4 divisibleBy 2

Thanks.

+3  A: 

Use

:- op(35,xfx,divisibleBy).

:- tells the Prolog interpreter to evaluate the next term while loading the file, i.e. make a predicate call, instead of treating it as a definition (in this case a redefinition of op/3).

larsmans
More precisely, that's called "directive" rather than "predicate call" or "predicate evaluation".
Giulio Piancastelli