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

Testing 2 variables

Status
Not open for further replies.

k3nnt0ter0

Programmer
Sep 13, 2012
1
PH
I am creating a Zodiac Sign and Chinese Zodiac Sign. I am done with the Chinese Zodiac Sign and the only thing left is the Zodiac Sign. How do I test two variables?
Like for example,
M=Month, D=Day.
If M=1, D<=19, write("Capricorn").

Something like that.

My Original code was something like this,
write("Month: "), readint(M), write("Day: "), readint(D), try(M), try(D).
M=1,D<=19,write("Capricorn"); and so on...

My code isn't working yet. That was just to explain what I want.

Hope you help me:)
 
You should define signs then write a predicate to find the sign :
Code:
sign(belier, 3-21,4-19).
sign(taureau, 4-20,5-20).
sign(gemeaux, 5-21,6-21).


is_sign(X, Month, Day) :-
	sign(X, BM-BD, EM-ED),
	(   BM = Month, Day >= BD; EM=Month, Day =< ED).
For example
Code:
 ?- is_sign(X, 5, 31).
X = gemeaux .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top