prolog - 在 Prolog 中获取运算符谓词的结果
问题描述
我试图了解运营商。
我为它定义了以下运算符和方法。
:- op(600, xfy, ⧺).
⧺(Left, Right) :- concatAtoms([Left, Right], _). % _ would the result but can´t be returned without an extra parameter
% concatenates atoms, e.g. [a,b] = ab
concatAtoms([H|T], R) :-
concatAtoms(T, H, R).
concatAtoms([], R, R).
concatAtoms([H|T], Atom, R) :-
atom_concat(Atom, H, Res),
concatAtoms(T, Res, R).
查询
?- a⧺b.
按预期返回 true。
有没有办法让它回来
ab
而是(由 concatAtoms 谓词计算)?
解决方案
推荐阅读
- jenkins - Jenkins - 如何在声明性管道中指定 Active Choice Reactive 参数?
- java - 如何在当前位置拆分字符串?
- javafx - 缺少一些 JavaFX 文档 (NetBeans 11)
- amazon-web-services - 为 AWS 无服务器应用程序的验收测试播种数据
- java - 如何从自定义数据源创建图表或表格
- python - 使用 scipy 的 solve_ivp 在时间步之间运行代码
- .htaccess - htaccess 重定向 301 保留 id
- ruby - Active Record 默认属性(从基础表中选择列)
- coldfusion - 在 CF 中,我可以使用变量作为名称来调用自定义标签吗?
- javascript - 如何继续添加从每个函数调用获得的结果到数组?