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!

Add possible values of a variable - it's sounds easy!

Status
Not open for further replies.

JohnyLehman

Programmer
Nov 16, 2004
1
DE
Given is this:

someNumbers(2).
someNumbers(3).
someNumbers(5).

How can I write a predicate to add these numbers and get the result - eg. "10" in this example ? Something like:

sumOfSomeNumbers(X) :- ...

To do it with a list [2,3,5] is very easy. You can use recursion. But how can I make it in this way?

Any kind of help is valuable.

Thanks,
Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top