序言从化合物中得到一个术语

prolog get a term from a compound

我得到这个复合词:

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

我怎样才能从那个化合物中单独得到 http://localhost:9000/? 或者更少,有没有办法将复合术语转换为字符串或列表?

一般情况下,您会为此使用统一:

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

"http://localhost:9000/" 绑定到 X

当您通过在查询中用变量代替术语来隐式执行此操作时,您也使用统一,例如:

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

将为每个匹配结果绑定到 X e 的第二个参数。