hiba hawes
hiba hawes

Reputation: 61

prolog get a term from a compound

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?

Upvotes: 5

Views: 1445

Answers (1)

fferri
fferri

Reputation: 18950

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.

Upvotes: 2

Related Questions