dragonwasrobot / learn-prolog-now-exercises

My solutions to the exercises and practical sessions of the book 'Learn Prolog Now!' by Patrick Blackburn, Johan Bos, and Kristina Striegnitz.
288 stars 81 forks source link

Fix exercise 11.3 solution to comply with the problem requirements #26

Closed ghost closed 8 years ago

ghost commented 8 years ago

It didn't comply with the following part of the problem:

Prolog should not calculate everything new, but shoud get the result for sigma(2, 3) from the database and only add 3 to that. Now mySigma also makes use of the cached values.

The cuts after the is goals were unnecessary since those goals have only one solution.

Moved the cut that is at the end of the mySigma inductive clause to the first base clause to match the mandatory cut in the second base clause.