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

Help me in a programme!

Status
Not open for further replies.

sealrochinha

Programmer
Sep 25, 2012
1
PT
Hi pll!

I start today learn prolog, and I need your help.

I have this:
"There are three types of emissions: alpha, beta and gamma."
"If there is an alpha and beta emissions, then a proton was detected."
"If there is an emission gamma, then a proton was detected."

I have to translate this for prolog.

I tried this, but it´s wrong:

emission(alfa).
emission(beta).
emission(gama).
detected(X) :- emission(alfa), emission(beta).
detected(X) :- emission(gama).


Sorry for my bad english.
 
You were nearly at the solution :
Code:
emission(alfa).
emission(beta).
emission(gama).
detected(proton) :- emission(alfa), emission(beta).
detected(proton) :- emission(gama).
You can write too :
Code:
emission(alfa).
emission(beta).
emission(gama).
detected(X) :- 
    % first case
    emission(alfa), emission(beta) ;
    % second case
    emission(gama).
Note that () are not necessary to enclose first case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top