Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想把这样的语法规则翻译成一个子句
char(C) --> [C], { code_type(C, graph), \+ memberchk(C, "()") }.
但不起作用
char(C,In,Out):- In=[C|Out], code_type(C, graph), \+ memberchk(C, "()").
您可以使用expand_term/2内置的 Prolog 谓词将语法规则扩展为子句:
expand_term/2
?- expand_term((char(C) --> [C], { code_type(C, graph), \+ memberchk(C, "()") }), Clause). Clause = (char(C, [C|_G1665], _G1651):- (code_type(C, graph), \+memberchk(C, [40, 41])), _G1651=_G1665).