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

If-Then-Else Needed Please Help

Status
Not open for further replies.

grant9

Programmer
Nov 30, 2004
3
GB
I need an if-then-else to add either A or B to C. I need to add the largest of A and B and put the result in total. I have tried with something like below but it doesnt work.

A > B ->
Total is A + C;
Total is B + C,

Any guidance will be appreciated.

Cheers
 
How about:
[tt]
max(A,A,B):- A >= B.
max(B,A,B):- B >= A.
addmax(Total,And,Or1,Or2):-
max(M,Or1,Or2),
Total is And + M.
[/tt]
Then:
[tt] addmax(T,123,456,789).[/tt]
will give:
[tt]T = 912[/tt]
 
That works perfect.

Thanks a lot TonyGroves.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top