# Assign an array of numbers to an array of variables

I have a huge array of variables like this.

variables=Flatten[Join[
Flatten[Table[
alpha[i, j, k, l, m, n], {i, 0, 2}, {j, 0, 2}, {k, 0, 2}, {l, 0,
2}, {m, 0, 2}, {n, 0, 2}]],
Flatten[Table[
beta[i, j, k, l, m, n], {i, 0, 1}, {j, 0, 1}, {k, 0, 1}, {l, 0,
1}, {m, 0, 1}, {n, 0, 1}]], {gamma}]]


I have an array of values, for the example let's take:

values=Flatten[Join[
Flatten[Table[
1, {i, 0, 2}, {j, 0, 2}, {k, 0, 2}, {l, 0,
2}, {m, 0, 2}, {n, 0, 2}]],
Flatten[Table[
1, {i, 0, 1}, {j, 0, 1}, {k, 0, 1}, {l, 0,
1}, {m, 0, 1}, {n, 0, 1}]], {gamma}]]


How can I assign each one of my variables inside my array corresponding values from values?

If I do variables=values, it will not set values to the alpha's or beta's but it will just change the variable "variables".

How can I say to mathematica to change the values of the variables alpha's and beta's stored in "variables" to affect them the value "1".

I could do a loop but I think there is a better option?

variables itself is a variable. When you do variables=values, you simply assign a value to it. You have to assign values to each of its elements. Something like as you suggested

Do[variables[[n]] = values[[n]], {n,Length[variables]}]


A better way is using MapThread which map elements from each array.

MapThread[(#1 = #2) &, {variables, values}]

alpha[0, 0, 0, 0, 1, 0]


1

you can also do this:

Inner[Set, Most@variables, Most@values, None];

Clear[alpha, beta, gamma]
Evaluate[variables] = values;


If the variables are still symbols with no value assigned the first line can be left out.