JohnyLehman
Programmer
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
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