2
我正在玩DCG,我有这个代码。这显示x
号码0
s和x
号码A
s。DCG加倍计数
y --> test(Count), as(Count).
test(0) --> [].
test(succ(0)) --> [0].
test(succ(succ(Count))) --> [0], test(Count), [0].
as(0) --> [].
as(succ(Count)) --> [a],as(Count).
我的问题是我如何通过一个函子,以使A
S的0
双打的数目。这是我的尝试,但它不起作用。
y --> test(Count), as(add(Count,Count,R)).
如果我只想添加一个,这是什么,它工作正常。
y --> test(Count), as(succ(Count)).
两个备注:使用而'到位SUCC的''S(X)(X )'。 ''set_prolog_flag(double_quotes,chars)'和'“0”'代替'[0]''。 – false