Search code examples
prologdcg

How to bind variable using DCG in prolog


enter image description here enter image description here

Based on the code in the pics, How can I bind those unbounded variables with processing the structure? For example, how can I let the X=1,Y=2 for the example in first pic.

a more clear example:

I asked another question to be more specific. if it is still unclear,whatever.

how to do Arithmetic Operations in DCG in prolog


Solution

  • Your question is still unclear. You don't bind anything "manually", do you?

    Do you mean that you do the unification in the head of the predicate?

    foobar(1, 2) --> [1, 2].
    

    (A trivial example, since I don't know if this is what you are asking.)