I have a list like
['_', '_', '#', '_']
Is there any way I can let system generate some different variables and replace each '_' with one of the variables? Thanks
I have a list like
['_', '_', '#', '_']
Is there any way I can let system generate some different variables and replace each '_' with one of the variables? Thanks
Simple implementation:
var('_', _):- !.
var(X, X).
Example run:
?- maplist(var, ['_','_','#','_'], L).
L = [_G313, _G316, #, _G322].
The cut (exclamation mark) is used to leave out any choicepoints. (Try leaving the cut out, you will see that you will get an idle choicepoint by pressing semicolon.)