CarlJohnson
CarlJohnson

Reputation: 13

Prolog Trying to Print But Get Errror

Why do I get the error "uncaught exception: error(type_error(evaluable,'Jack'/0),(is)/2)" when printing the name.

"test(180)."

info('Mike','Ross',166).
info('Jack','John',180).

test(Name):- info(Y,_,T),T>170, Name is Y.

Upvotes: 1

Views: 67

Answers (2)

TA_intern
TA_intern

Reputation: 2422

You don't need the is at all, your rule should be:

test(Name):- info(Name,_,T),T>170.

then:

?- test(Name).
Name = 'Jack'.

Upvotes: 0

David Tonhofer
David Tonhofer

Reputation: 15316

That's because is is the instruction to perform arithmetic evaluation of the right-hand-side.

In this case, Y, which is instantiated to Jack.

However, Jack/0 (Jack with no arguments) is not an arithmetic function. Hence, an exception.

Upvotes: 1

Related Questions