访问序言列表术语
我一直在使用 jpl 从 java 调用 prolog。我在 java 中使用以下代码从 prolog 中获取 X 的值。
String t4 = "myNumber(X)";
Query q4 = new Query(t4);
System.out.println( "first solution of " + t4 + ": X = " + q4.oneSolution().get("X"));
我的解决方案是——
first solution of myNumber(X): X = '.'(2, [])--which is true.
我现在想做的是从解决方案中获取值 2 并将数字加倍。 谁能帮我解决这个问题吗?
I've been using jpl for calling prolog from java. I'm using the following code in java to get the value of X from prolog.
String t4 = "myNumber(X)";
Query q4 = new Query(t4);
System.out.println( "first solution of " + t4 + ": X = " + q4.oneSolution().get("X"));
And my solution is--
first solution of myNumber(X): X = '.'(2, [])--which is true.
What i wanted to do now is to obtain the value 2 from the solution and double the number.
Can anyone help me how to handle that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
oneSolution() 返回变量名到术语绑定的哈希表 (他们说)。然后你必须检查该术语(未经测试):
还要检查 Term 的文档。
编辑:修正错误
oneSolution() returns a hashtable of variablename-to-term bindings (they say). Then you have to inspect to the term (untested):
Also check Term's documentation.
Edit: fixed mistakes