SICStus Prolog 4.3.2:clpfd 没电了? [英] SICStus Prolog 4.3.2: clpfd got no power?

查看:68
本文介绍了SICStus Prolog 4.3.2:clpfd 没电了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一些 Prolog 程序可以相当获利,如果我可以用它们替换基于所有(is)/2的整数算法 对应.

所以我想要力量......使用 ...所以我可以用 clpfd-y 替换 X is 10^3 :)

考虑以下五个支持 的 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

想法/提示/建议,请.我能做什么?也许使用一些 兼容层?

先谢谢你!

解决方案

快速解决方案?

警告:前面有大量的矫枉过正,但是......它甚至有效吗?它是便携式的吗?

我们来看看吧!

  • SWI-Prolog 7.3.14

    • 使用

      <前>?- use_module(图书馆(clpq)).真的.?- clpq:{X = 10^3}, 整数(X).X = 1000.% <== 成功!

    • 使用

      <前>?- use_module(图书馆(clpr)).真的.?- clpr:{X = 10^3}, 整数(X).错误的.

  • 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 counterpart.

So I want the power ... with ... so I can replace X is 10^3 with something clpfd-y :)

Consider the following five Prolog processors supporting :

  • 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 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

      ?- use_module(library(clpq)).
      true.
      
      ?- clpq:{X = 10^3}, integer(X).
      X = 1000.                          % <== SUCCESS!
      

    • using

      ?- use_module(library(clpr)).
      true.
      
      ?- clpr:{X = 10^3}, integer(X).
      false.
      

  • SICStus Prolog 4.3.2

    • using

      ?- use_module(library(clpq)).
      true.
      
      ?- clpq:{X = 10^3}, integer(X).
      false.
      

    • using

      ?- 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆