Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menu help

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I've successfully created a menu system that links to my family geneology, so that the menu asks for a name, then the relation and Prolog lists the relations eg the mother of this person is....

However when there is more than 1 person in a relationship eg a person has 2 brothers or 2 grandfathers only the fisrt persn is listed, how do i change this?

The Prolog i've used is as follows;

choice(c,Name):-brother(X,Name),
write('The brother(s) of this person is/are '),
write(X),nl.

Hope you can help Dylan

 
Try this:
choice(c,Name):-
write('The brother(s) of this person is/are '),!,
brother(X,Name),
write(X),nl,
fail.
choice(_,_). %to force returning 'Yes'
fail&cut(!) are pretty useful in a such cases!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top