gpt4 book ai didi

prolog - DCG 中的花括号 { }

转载 作者:行者123 更新时间:2023-12-01 14:33:44 24 4
gpt4 key购买 nike

我开始学习如何使用 DCG。我想知道花括号 {...} 的用途是什么?何时(何时不)需要它们?例如:

read_lines -->
{ read_line_to_codes(current_input, Codes) } ,
(
{ Codes == end_of_file } -> []
;
{ atom_codes(Line, Codes) } ,
[Line],
read_lines
) .

为回答这个问题而提供:Avoid linear cost of append/3 in Prolog

最佳答案

在 DCG 规则中,{} 用于封装 Prolog 目标,否则这些目标将被解释为非终结符。

关于prolog - DCG 中的花括号 { },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18298228/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com