I expect the following code to print out [9 4], but this isn’t working
:- op(20,xfx,i).
i(X,Y, Z) :-
Z=[X,Y].
main:-
RESULT is 9 i 4, write(RESULT).
Where am I getting wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
an operator is basically syntactic sugar; instead of writing
+(1,2)we simply write1+2.therefore,
9 i 4is equivalent toi(9,4)now, +/2 is not only an operator but also an arithmetic function
note that the result should be a number so you cannot use it to return a list (and cannot use is/2 either)