I am confused about ordering arguments in Prolog, for example a predicate like between/3
that represents the relationship between 3 people sitting in an order (let's say Susan sits between Ali and John), the problem is should it be between(Susan, Ali, John)
or between(Ali, Susan, John)
?
Please note that the between/3
predicate is different from the built-in one, it's just an example.
I expect it to be the first one, however in an exam I had -few days ago- it says that the correct answer is the second as Susan relies between the other two arguments. What I understands is if the predicate was sit/3
it would be the second one, but for the between/3
one Susan should come first as that's how we express predicates in Prolog (in their order in English) like if we want to express "Susan likes John" it would be likes(Susan, John)
not likes(John, Susan)
.
So what do you think the correct order should be? Please provide some clarification why you think so.
Looking at (mostly) built-in Prolog predicates, I see 4 main general conventions, which all have sensible reasons:
parent(mary, fred)
reads as "mary is a parent of fred"https://www.swi-prolog.org/pldoc/doc_for?object=between/3 has the reasonably standard order of the 2 required arguments (upper and lower limits) being specified first, and the (changeable upon backtracking) result being the last argument.
To my mind, given that between/3
is well-known, it would be very odd if an exam question used the standard, built-in predicate of between/3 and changed the argument order.