1

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).
xmen
  • 9
  • 1
  • 6
  • 2
    Take a loo at [this](https://stackoverflow.com/a/36845526/1243762) for ideas. – Guy Coder Jul 07 '17 at 10:25
  • *but it has proven ineffective.* Could you be specific? What query did you try? What results did you expect? What results did you get? – lurker Jul 07 '17 at 23:19

0 Answers0