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 the solution to exercise 9.4 to work with nested terms #21

Closed ghost closed 8 years ago

ghost commented 8 years ago

The previous solution was producing wrong answer to the following query:

?- groundterm(foo(bar(_))).
true.

It is important to note that groundterm_in_list should be called in groundterm with a list that does not consist the functor, otherwise we would end up in an infinite loop. For example:

?- groundterm(1).
Out of stack error