【问题标题】:SWI Prolog pass a goal with non-zero arity through the command line argumentsSWI Prolog 通过命令行参数传递一个非零参数的目标
【发布时间】:2015-06-07 21:29:10
【问题描述】:

SWI Prolog 允许在顶层之前执行一个非零参数的目标,如下所示

swipl -s consultingfile.pl -g start

然而,当一个非零元的谓词被指定如下时

swipl -s consultingfile.pl -g start(1)

报错

syntax error near unexpected token '('

应该怎么做才能在顶层之前将非零元数谓词作为目标传递?

【问题讨论】:

  • 如果你把它放在引号之间呢?

标签: bash prolog swi-prolog logic-programming


【解决方案1】:

我认为这与 SWI-prolog 本身无关/没有太大关系,而与命令行处理程序有关。

如果我将目标放在单引号 ('') 之间,它会起作用:

swipl -s consultingfile.pl -g 'start(1)'

括号可能被 shell 错误地解释了。

如果我使用你的命令,它会给出:

$ swipl -s consultingfile.pl -g start(1)
bash: syntax error near unexpected token `('

请注意冒号前的bash。这意味着控制权从未真正授予swipl,抱怨括号的是bash。

一般来说,最好将项目放在引号中,以便将内容分组为单个参数。

【讨论】:

  • 谢谢。这有帮助:) 太愚蠢了,我错过了尝试 XD
猜你喜欢
  • 1970-01-01
  • 2014-10-17
  • 1970-01-01
  • 1970-01-01
  • 2021-11-29
  • 1970-01-01
  • 2021-12-13
  • 1970-01-01
  • 2023-03-19
相关资源
最近更新 更多