I would like to replace a sequence of tokens in a DCG grammar in Prolog. In other words replace the sequence or sublist A: [a,a,a,a] by the sublist B: [b].
chain --> chain_where_sublist_A_is_replaced_by_sublist_B but entirely using the DCG formalism.
For example: [c,a,a,a,a,d] gives [c,b,d]
As at Prolog - substitute substring of string by letter not used in string itself
In swi-prolog: