# Assign Values from Array to Array [duplicate]

I am trying to simply do the following

cVec = {a,b,c,d}

From another expression, I obtain another vector, say,

uVec = {k,l,m,n}

What I try to do is to assign each value to other value, like:

a = k
b = l
c = m
d = n


As you may imagine, I do not have four values but several values, so writing each assignment would be cumbersome. I am trying to find easy way to assign the values.

Any help would be really appreciated, thank you.

• Will you do this assignment more than once? Why not consider using an Association instead? Note that both of the answers below will only work once. – Carl Woll Oct 21 at 20:23
• I will do this only once, yes. So far, the given answers are sufficient to solve my problem. Since I am quite new to Mathematica, I do not know how Association works. I will check it also. Thank you. – nicomedian Oct 21 at 20:24
• @nicomedian Welcome to Mathematica.SE. I have marked your question as a duplicate; please see the links inserted above your post for existing Q&A's on this topic. This does not mean your question is bad, it is a matter of site organization. – Mr.Wizard Oct 21 at 22:15

cVec = {a, b, c, d};
uVec = {k, l, m, n};

With[{z = cVec}, z = uVec];

a


k

also

Clear[a, b, c, d]

x = cVec;

With[{z = x}, z = uVec];

• That worked great, thank you. Is there a way not to write explicity cVec in With[] command but define it above? – nicomedian Oct 21 at 20:22
• Yes, now updated. – Chris Degnen Oct 21 at 20:32
• Thank you for your answer. – nicomedian Oct 21 at 20:34
ClearAll[cVec, uVec, a, b, c, d, k, l, m, n];
cVec = {a, b, c, d};
uVec = {k, l, m, n};

• Thank you for your answer. – nicomedian Oct 21 at 22:18

You can use Set wrapping cVec with Evaluate:

Evaluate[cVec] = uVec;
cVec


{k, l, m, n}

c


m

You can also use MapThread:

ClearAll[cVec, a, b, c, d]
cVec = {a, b, c, d};