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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PROLOG if statements

Status
Not open for further replies.

Samohtvii

Programmer
Aug 2, 2012
21
0
0
AU
Ok I haven't really found any clear way of doing an If statement in PROLOG. I want to read a word into a variable and then run either one of 2 functions if the answer is yes or no.
Bare in mind I am very new to PROLOG so here is what I have:

read(Var),
yesVar :-
Var="Yes", yesFunction(Var), noFunction(Var).

Any help?

Thanks
 
This is possible :
Code:
t :-
	read(Var),
	(   Var = yes -> yesFunction(Var); noFunction(Var)).
 
That doesn't seem to work. Any other thoughts.
 
What do you mean by "That doesn't seem to work", it works well with SWI-Prolog.
 
Sorry, all good. Had to change some of my code but got it. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top