How can Prolog be used to parse this arbitrary string?
S → DZ
D → dD
D → d
Z → zZ
Z → z
So far I have this code, but it has proven ineffective. A represents the input and B represents the resulting string.
s(A,B):- d(A,C), z(C,B).
d([d,d|A],A).
z(z,z|A],A).