For example, I input four node:
node(a). node(b). node(c). node(d).
Without no hard-code, how can I pick an arbitrary input as a variable.
I set a root(A)
I want root(A) equal to node(a)
For example, I input four node:
node(a). node(b). node(c). node(d).
Without no hard-code, how can I pick an arbitrary input as a variable.
I set a root(A)
I want root(A) equal to node(a)
You can add the clause root(A):- node(A).
, then you will also get root(a)
, ..., root(d)
in the answer set.
Something like
root(X) :- X=#min{V : node(V)}.
should do the trick. This takes the lexicographically smallest one (which is kind of arbitrary ;) ).