Search code examples
prologeclipse-clp

why this code cannot be run?what is "syntax error: postfix/infix operator expected" error in ECLiPSe-clp


When I want to run this code in ECLiPSe-CLP I get the following Error

Error:
string stream 27: syntax error: postfix/infix operator expected

|     4 $= X^2 + Y^2,   (Error Mark is under '=')
|           

Code:

circles(X, Y) :-
    4 $= X^2 + Y^2,
    4 $= (X - 1)^2 + (Y - 1)^2,
    X $>= Y.

Solution

  • The $=/2 operator/predicate is a library predicate. Are you loading the library defining it? E.g.

    [eclipse 12]: lib(ic).
    ...
    Yes (0.12s cpu)
    
    [eclipse 13]: [user].
    circles(X, Y) :-
         4 $= X^2 + Y^2,
        4 $= (X - 1)^2 + (Y - 1)^2,
         X $>= Y.
     ^Dtty        compiled 4024 bytes in 0.00 seconds
    
    Yes (0.00s cpu)
    
    [eclipse 14]: circles(X, Y).
    
    X = X{-1.0000000000000004 .. 2.0000000000000004}
    Y = Y{-1.0000000000000004 .. 2.0000000000000004}
    
    There are 13 delayed goals. Do you want to see them? (y/n)