CSE
CSE

Reputation: 53

Prolog Rules/Queries

Given the following facts:

people(ana, az, 13).

people(sam, ca, 24).

people(tom, il, 5).

people(ginger, ca, 52).

How would I write a prolog rule that answers the following question?

Person is the adult if he is greater than 17 years of age?

This is what I have so far.... (Thanks in advance I'm new at this)

is_adult(Person):-
    people(Person, State, Age).
    Age>17.

Upvotes: 0

Views: 991

Answers (1)

Alexander Serebrenik
Alexander Serebrenik

Reputation: 3577

You have probably taken the altitude from some other example, right?

This how it should look like

is_adult(Person):-
    people(Person, State, Age),
    Age>17.

Upvotes: 2

Related Questions