I am playing around with DCGs and I have this code. This displays x
number of 0
s and x
numbers of A
s.
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).
my question is how do I pass a functor to make the number of A
s double the number of 0
s. Here's what I tried, but it doesn't work.
y --> test(Count), as(add(Count,Count,R)).
If i only want to add one, this is what did and it works fine.
y --> test(Count), as(succ(Count)).
y --> test(Count), as(Count), as(Count).
or
y --> test(Count), {add(Count,Count,DCount)}, as(DCount).