问题标签 [mercury]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
mercury - Mercury 是否支持代数谓词?
我对 Mercury 和一般的逻辑编程非常陌生。我在文档或示例中没有找到这样的数字示例...
以示例谓词为例:
有了这个,A 必须接地,B 是自由的。如果我希望 A 自由而 B 接地(例如,添加mode diffThirtyFour(out,in) is det.
)怎么办。这种代数可以在编译时执行吗?我可以很容易地定义另一个谓词,但这似乎不太合乎逻辑......
更新
所以,像这样的作品:
有点警惕semidet
,和第二个目标的冗余。这是唯一的方法吗?
更新 2
这可能是答案......它在编译时发出警告,说明分离永远没有任何解决方案。一个正确的警告,但可能是不必要的代码气味?这可以满足我的需要,但如果有更好的解决方案,请随时发布它们......
mercury - 当 Microsoft 管理控制台应该是 Melbourne Mercury 编译器时,Windows 将 mmc 错误
我采取了这些步骤:
但 Windows 会为 Microsoft 管理控制台弹出一个对话框。
如何在 .m 文件上调用 Melbourne Mercury 14 编译器?之前的 stackoverflow 问题是针对 Mercury 11.07.1 的,它指的是 Mercury 14 中没有的 README 文件。
Mercury 适合我希望的跨平台工具链:
平台:Windows 10、Mercury 14、Visual Studio Community 2017
mercury - How do I specify compile time defines in Mercury?
How do I specify compile time defines in Mercury?
I would like to have the build system read the version number out of a configuration file and pass it into the module for access by predicates and functions.
For example, in C I'd do something like: gcc -DVERSION="1.2.0", and then use the newly defined macro VERSION in the source.
mercury - 是什么导致 Mercury 中函子“field_name/1”的参数类型错误?
当我编译我的源代码时,我收到以下错误:在仿函数“source/1”的参数中输入错误
编译器正确确定参数的类型,但不断尝试使用不同记录中的字段。
怎么了?
clp - Mercury 约束求解
我知道一点 Prolog,并且经常使用 CLP(FD) 等。 这篇论文(显然写于 2006 年)表明 Mercury 现在也有约束求解。我在图书馆参考手册中发现了一些提及它。 但是,我找不到如何使用它。例如:
给出编译器错误
但在 Prolog 中,使用 clpfd,
工作正常,给 A = 2 。
(在 Mercury 代码中添加 #s 无济于事。)
您如何在 Mercury 中进行约束求解?
mercury - Det 中的 Mercury nondet
在 Mercury 中,假设您在一个det
谓词中,并且您想调用一个nondet
谓词,如下所示。如果没有解决方案,你想要Result = []
;如果有一个或多个,你只想要第一个喜欢Result = [FirstSolution]
. 谓词可能有无限数量的nondet
解,因此您无法将它们全部枚举并取第一个。我最接近的是使用do_while
并在第一个解决方案之后停止,但do_while
显然cc_multi
我不知道如何将它强制回到det
上下文中,甚至回到multi
上下文中以便我可以应用solutions
它。
functional-programming - 从术语/目标列表中查找成功次数
如果列表中的数字exactly/2
恰好等于 1 ,我编写了以下谓词:N
L
例如,调用exactly(X, [1, 0, 0, 1, 0, 1])
将绑定X
到3
.
N
我想创建类似的东西,但对于谓词:如果列表中的目标完全成功,我想编写一个成功的谓词L
。
例如,调用exactly(X, [true, false, member(1, [1, 2, 3]), member(0, [1, 2, 3])])
应该绑定X
到2
.