Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prolog get a term from a compound

Tags:

prolog

I get this compound term:

e(currentNode,"http://localhost:9000/")

How can I get only http://localhost:9000/ separately from that compound? Or less, is there a way to transform the compound term to a string or a list?

like image 677
hiba hawes Avatar asked Oct 31 '22 22:10

hiba hawes


1 Answers

In general you use unification for that:

e(currentNode,"http://localhost:9000/") = e(_,X).

will bind "http://localhost:9000/" to X.

You use unification also when you this implicitly by putting variables in place of terms in your query, e.g.:

?- comp(e(_,X)).

will bind to X the second argument of e for every matching result.

like image 183
fferri Avatar answered Nov 15 '22 11:11

fferri