Reputation: 1699
I need to define a new operator that associates in the following way
(1 newop 2) / (2 newop) / a
The parenthesis were just used to give an understanding of the associativity of the new op
So.
:- op(A, B, newop).
Which would be the values for A and B.
Thanks in advance.
Upvotes: 2
Views: 149
Reputation: 10102
What you want is that newop
serves both as an infix operator as in (1 newop 2)
and as a postfix operator as in (2 newop)
.
This is impossible in ISO Prolog. In subclause 6.3.4.3 of ISO/IEC 13211-1:1995 it is stated:
There shall not be an infix and a postfix operator with the same name.
That said, there are implementations that still permit this. However, be aware that such implementations ofter differ in subtle ways.
Upvotes: 4
Reputation: 1699
infix operator: xfx
precende should be higher than "/"
precende for / is 400
:- op (300, xfx, newop).
Upvotes: 0