Implement the division operator in a way that: A is 12 div 6 div 2 result is: A = 4
So I think that I have to create an infix operator belonging to the type: yfx because this operator have first to calculate 6 div 2 and then calculate 12 div result(6 div 2)
I hope to be clear in my explanation...I know that I have explained the concept in a procedural way, but I did not know how else to express the precedence of the operations to be performed on arguments...
Ok, so I think (I hope) that the yfx form of operator is correct...
The problem is that now I don't know how to describe this operator.
In a previous exercise I have defined operator in this way:
op(600,xfx,has).
/* perter has information */
has(peter, information).
As I can read on Ivan Bratko book:
The operator definitions do not specify any operation or action. In principle, no operation or data is associated with an operator.
So I think that I can't define an operator that performs calculations.
So I think that a solution of my exercise could be something like:
op(600,yfx,div).
div(X div Y, Division) :- Division is X/Y.
But don't work well and moreover I think that this is not that they asking me to implement.