learn-prolog-now-exercises
learn-prolog-now-exercises copied to clipboard
My solutions to the exercises and practical sessions of the book 'Learn Prolog Now!' by Patrick Blackburn, Johan Bos, and Kristina Striegnitz.
Hi, I think the correct answer is 7 clauses and 5 (not 7!) predicates.
In chapter 6 it is possible to create a swapfl/2 using only the append/3 rule.
``` cd chapter-11 swipl practical-session.pl powerset([a,b,c,d,e],P). P = [[], [a], [a, b], [a, b, c], [a, b, c, d], [a, b, c|...], [a, b|...], [a|...], [...|...]|...]. ```
Are you sure about the solution? It looks like OUT OF LOCAL STACK will be occur.
Hi, The solution provided will asset that subset([a,b,c,a], [a, b, c]). is true. It is missing checking that the first parameter is a set itself. Here I propose a fix...
I belive there is a bug. The current definition has the following outputs: ``` ?- display(p or r and s). or(p,and(r,s)) true. ``` Which is ok but: ``` ?- display(p...
I tried the following `assert([[1,2]|4]).` and it returned true. Why is it labelled as syntactically incorrect?
Specifically, it uses the `not/1` predicate, which is not given in the text, and negation in general is not discussed until chapter 10. Unfortunately, I don't think there's a way...
Changed the solution as not/1 predicate has not been introduced yet and I think should not be used.