In my programming languages class we were running the program below:
range(X,Y,Z) :- X>=Y,X<=Z
This would not compile and after a short google search we discovered that prolog uses the =< opporator rather than <= like most other languages we have learned about.
Does anyone have any insight on why prolog does this? Is there a reason?
Thanks in advance.
Yes, there is a very good reason: <=
looks like an arrow, and since Prolog is also often used for logical proofs, this is "reserved" to accomodate such uses when they are needed, denoting implication from right to left.
By the way, (=<)/2
is quite low-level. Better use constraints to make your programs more general and easier to understand.