variables - Binding symbols and querying symbol values in Prolog -
i have difficulty doing basic things in swi prolog. starters, how have function binds symbol value? here's tried, don't know if it's correct:
bind(name) :- assert(name = 'a').
now if run bind(test).
in interpreter symbol test
bound value 'a'
. way it? if is, how query value of symbol?
are asking such basic thing unification in prolog?
if have predicate
bind('a').
defined, in other predicate, after calling
.... , %// #1 bind(x), %// #2 ....
x
hold 'a'
value below point #2, until backtracking occurs (if any) above point #2.
but there's no need separate bind
predicate that. unification signified =/2
built-in operator, , same effect achieved with
.... , %// #1 x = 'a', %// #2 ....
if try in swi prolog console,
1 ?- x = 'a'. x = 'a'.
you can access later
2 ?- z = $x. z = 'a'.
but if want more tangible, should assert database, under functor name of choice, you're advised in capellic's answer.
Comments
Post a Comment