I have simplified a more complex problem to the following: there are three houses on a street with three different colours (no colour repeated); red, blue, green. Write a program using DCGs to simulate all permutations/possibilities. My code won't run and I'm struggling to see why. Any corrections would really help.
s --> h(X), h(Y), h(Z), X\=Y, X\=Z, Y\=Z.
h(X) --> Col(X).
Col(X) --> [red].
Col(X) --> [blue].
Col(X) --> [green].
s/Col/col/And then, you are using within
s//0Prolog goals in the place of non-terminals. That does not work, you need to "escape" them with{}//0like soBut I would rather write:
In this manner Prolog performs all the bookkeeping for you.
If we're at it. Don't forget to call the non-terminal via
phrase/2. Thus: