I want to write a (Prolog) DCG which takes in strings of the form a2rev(a)
where a is a string of binary bits, e.g. 1012101, 001121100, 0111002001110. My idea was the following :
reverse([]) --> [].
reverse([H|T]) --> reverse(T), [H].
s--> [2].
s--> a,2,b.
a--> [0];[1].
reverse(a,b).
This doesn't work - I am unsure whether I am calling the reverse
function incorrectly or if a --> [0];[1]
makes sense.
Any help appreciated