1

I'm writing a Prolog predicate that retuns a list of variables. Right now the list of variables are _ (underscored) variables, for example:

Xs = [_2654, _2690],
.
.
.

And I would like to label these variables with an increasing index, for example:

Xs = [X1, X2],
.
.
.

Is there any trick to label these variables?

Edit: So it is probably not easy to do and probably not necessary, but because some of the commenters wanted more info, I was implementing a logic addition circuit, which is composed of full adders.

full_adder(X, Y, Cin, Z, Cout)

and wanted meaningful variable names like:

?- addition_circuit(2, Xs, Ys, Zs, Fs).
   Xs = [X1, X2],
   Ys = [Y1, Y2],
   Zs = [Z1, Z2, Z3],
   Fs = [ full_adder(X1, Y1, 0, Z1, C2),
   full_adder(X2, Y2, C2, Z2, Z3)
   ]

Thanks for the help. I'll stick with the underscored variables for now.

chendoy
  • 155
  • 1
  • 2
  • 12
  • 1
    Of interest: [How to assign meaningful names to (fresh) variables?](https://swi-prolog.discourse.group/t/how-to-assign-meaningful-names-to-fresh-variables/1505) – Guy Coder Apr 10 '20 at 15:20
  • Can you be more specific as to why the variables need names? Is it for printing, writing to a file or using in code elsewhere, etc.? – Guy Coder Apr 10 '20 at 15:21
  • Use another toplevel or another system. – false Apr 10 '20 at 19:30
  • Of relevance, you can use something like numbervars(Xs, 0, _End,[functor_name('X')]), to get [X(0), X(1)], which is however not exactly what you are looking for... – damianodamiano Apr 10 '20 at 20:50
  • I've edited my post with a bit more info. No help needed anymore, just for the sake of the future readers. – chendoy Apr 12 '20 at 19:34

0 Answers0