如何在 Prolog 中双统一术语运算符?
我刚刚在如何统一Prolog中的术语运算符?<中提出了问题/a> 并得到了很好的答案。
但是,它并没有完全解决我的问题,即 =..
仅适用于单面。
例如,
test(Expr) :-
1 + 2 = Expr.
test(Expr) :-
1 * 2 = Expr.
?- E =.. [Op, X, Y], test(E). % E can not be a variable!
ERROR: Arguments are not sufficiently instantiated
我希望查询返回
Op = (+),
X = 1,
Y = 2;
Op = (*),
X = 1,
Y = 2.
非常感谢。
I just asked the question in How to unify a term's operator in Prolog? and got good answers.
However, it doesn't completely solve my problem, i.e. =..
only works for single-side.
For example,
test(Expr) :-
1 + 2 = Expr.
test(Expr) :-
1 * 2 = Expr.
?- E =.. [Op, X, Y], test(E). % E can not be a variable!
ERROR: Arguments are not sufficiently instantiated
I hope the query returns
Op = (+),
X = 1,
Y = 2;
Op = (*),
X = 1,
Y = 2.
Very thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

由于完全历史的原因,这也可以称为Boomy Univ。
This could also be called a boomy univ for entirely historical reasons.