SICStus Prolog 4.3.2:clpfd 没电了? [英] SICStus Prolog 4.3.2: clpfd got no power?
问题描述
我的一些 Prolog 程序可以相当获利,如果我可以用它们替换基于所有(is)/2
的整数算法clpfd 对应.
所以我想要力量......使用 clpfd ...所以我可以用 clpfd-y 替换 X is 10^3
:)
考虑以下五个支持 clpfd 的 Prolog 处理器:
GNU Prolog 1.4.4
<前>?- X #= 10^3.未捕获的异常:error(type_error(fd_evaluable,(^)/2),(#=)/2)?- X #= 10**3.X = 1000.SWI-Prolog 7.3.14
<前>?- use_module(library(clpfd)).% 自动加载会更棒真的.?- X #= 10^3.X = 1000.?- X #= 10**3.错误:域错误:应为clpfd_expression",找到10**3"B-Prolog 8.1
<前>?- X #= 10^3.X #= 10^3.*** 错误(illegal_array_access,10^3)?- X #= 10**3.X = 1000.SICStus Prolog 4.3.2
<前>?- use_module(library(clpfd)).真的.?- X #= 10^3.!(^)/2 中的存在错误!约束用户:wi(^)/2 不存在!目标:10^3?- X #= 10**3.!用户存在错误:(**)/2!约束用户:(**)/2 不存在!目标:10**3
想法/提示/建议,请.我能做什么?也许使用一些 clpfd 兼容层?
先谢谢你!
快速解决方案?
警告:前面有大量的矫枉过正,但是......它甚至有效吗?它是便携式的吗?
我们来看看吧!
SWI-Prolog 7.3.14
SICStus 序言 4.3.2
1X 成功,3X 失败......有效,嗯,有点......再说一次,我想不是这样.
Some of my Prolog programs could profit quite a bit if I could replace all (is)/2
-based integer arithmetics by their clpfd counterpart.
So I want the power ... with clpfd ... so I can replace X is 10^3
with something clpfd-y :)
Consider the following five Prolog processors supporting clpfd:
GNU Prolog 1.4.4
?- X #= 10^3. uncaught exception: error(type_error(fd_evaluable,(^)/2),(#=)/2) ?- X #= 10**3. X = 1000.
SWI-Prolog 7.3.14
?- use_module(library(clpfd)). % autoload would be even more awesome true. ?- X #= 10^3. X = 1000. ?- X #= 10**3. ERROR: Domain error: `clpfd_expression' expected, found `10**3'
B-Prolog 8.1
?- X #= 10^3. X #= 10^3. *** error(illegal_array_access,10^3) ?- X #= 10**3. X = 1000.
SICStus Prolog 4.3.2
?- use_module(library(clpfd)). true. ?- X #= 10^3. ! Existence error in (^)/2 ! constraint user:wi(^)/2 does not exist ! goal: 10^3 ?- X #= 10**3. ! Existence error in user:(**)/2 ! constraint user:(**)/2 does not exist ! goal: 10**3
Ideas / hints / advice, please. What can I do? Use some clpfd compatibility layer(s), perhaps?
Thank you in advance!
Quick hack to the rescue?
Warning: massive overkill ahead, but... does it even work? And is it portable?
Let's check it out!
SWI-Prolog 7.3.14
using clpq
?- use_module(library(clpq)). true. ?- clpq:{X = 10^3}, integer(X). X = 1000. % <== SUCCESS!
using clpr
?- use_module(library(clpr)). true. ?- clpr:{X = 10^3}, integer(X). false.
SICStus Prolog 4.3.2
using clpq
?- use_module(library(clpq)). true. ?- clpq:{X = 10^3}, integer(X). false.
using clpr
?- use_module(library(clpr)). true. ?- clpr:{X = 10^3}, integer(X). false.
1X success, 3X failure... Works, well, kind of... Then again, I guess it ain't it.
这篇关于SICStus Prolog 4.3.2:clpfd 没电了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!