OK, here's the question:
Give a DCG that generates the set of strings w?{0,1}* with the same number of 0's as 1's so that, for example
?- s([0,1,1,0],[]).
yes
?- s([0,0,1,1,],[]).
yes
?- s([1,1,0,1,0],[]).
no
Now, my program is this:
s--> [].
s--> z,s,o,s.
s--> o,s,z,s.
z--> [0].
o-->...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.