【问题标题】:Can I take the output of a swipl command and set it as the value of a variable with swi-prolog?我可以获取 swipl 命令的输出并将其设置为带有 swi-prolog 的变量的值吗?
【发布时间】:2020-10-06 22:14:15
【问题描述】:

我正在尝试在 shell 和 swi-prolog 之间编写一个接口,所以我希望(最好)让文本一次出现在一行中,但我明白为什么这不可能。 Swi-prolog 有一个 shell 谓词,它将给出 shell 命令的输出,但我不知道如何将该输出设置为变量。让 swipl 获取输出并再次打印它也可以。有什么想法吗?

【问题讨论】:

    标签: swi-prolog


    【解决方案1】:

    您的 shell 可以将其结果写入文件。然后调用您的 swi-prolog prog 将文件内容读入字符串并根据您的喜好重新格式化。例如。使用 DCG 之类的东西选择输出的部分作为您的价值。

    除非我错误地理解了你的问题,否则你希望它是另一种方式,prolog to shell。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-26
      • 1970-01-01
      • 2014-05-26
      • 2012-08-30
      • 2018-10-01
      • 1970-01-01
      相关资源
      最近更新 更多