swati saoji
swati saoji

Reputation: 2087

max predicate is not recognized by prolog SWI

When I query max , I get the following error

?-max(2,3).
ERROR: toplevel: Undefined procedure: max/2 (DWIM could not correct goal)

As i understand max is a library defined predicate and should work as is. I referred the http://www.swi-prolog.org/pldoc/man?section=arith and I find nothing wrong with the query. Similarly min( 2,3 ). wouldnt work either.

Although other functions like member , length are working fine. What could be wrong ??

Upvotes: 0

Views: 754

Answers (1)

user1812457
user1812457

Reputation:

Those are not predicates, they are arithmetic functions that need to be evaluated as such. For example, you can use is/2:

?- A is max(2, 3), B is min(2, 3).
A = 3,
B = 2.

or any other predicate/operator that take arithmetic expressions:

?- min(2, 3) > max(1, 0).
true.

Upvotes: 3

Related Questions