0

Is it possible to use atom as both operator and predicate. Something along the lines :

:- op(101, fy, rule).
:- op(99,  xfy, ==>).
rule(R) :- write_canonical(R).

So that I can say :

 rule ...blah... ==> ...abc..

instead of :

 rule( ...blah... ==> ...abc.).
Makyen
  • 31,849
  • 12
  • 86
  • 121
sten
  • 7,028
  • 9
  • 41
  • 63
  • Did you try it? It should work if your specify the precedence correctly. For example `2 + 3` and `'+'(2, 3)` evaluate the same way in an `is/2` call. – lurker Feb 09 '18 at 22:12
  • hmm.. tried it in isolation , it works... let me try in the bigger prj. – sten Feb 09 '18 at 22:18
  • Interesting resource which explains the case with [arithmetic examples](http://www.learnprolognow.org/lpnpage.php?pagetype=html&pageid=lpn-htmlse19) – G_V Feb 15 '18 at 13:21

1 Answers1

1

As lurker said, the problem was resolved when I set correct precedence.

In your specific case it will depend what else you have defined and how do you use it.

To check for conflicting precedence use current_op/3.

sten
  • 7,028
  • 9
  • 41
  • 63