# How can I assign some part of data from one list to another list?

I don't know this is correct question or not,but I have a doubt.

I have two Lists names are list1 and list2

 list1={a,b,c};
list2={10,20,30};


I want to assign Part[list2,1] value (10) to the Part[list1,1].that means Part[list1,1] act as Variable.

after assigning,

If I evaluate list1,it will shows {a,b,c},

if I evaluate list2,it will shows {10,20,30}.

if I evaluate a,it will shows 10.

I want like this..

Is it possible like this?

-
seems a bit contradictory... – chris Dec 27 '12 at 10:52

You can do a direct assignment:

{a, b, c} = {1, 2, 3}


Then, a will return 1, b will return 2 and so on. However, {a,b,c} will return {1,2,3}.

-

This general topic has been covered in Assigning values to a list of variable names and the questions linked below it.

Within the normal syntax of Mathematica you will need a Hold or similar device to achieve your objective. Depending on your actual use you will need to select between a number of different methods and compromises.

Understand that {a,b,c} cannot be returned raw if a, b, and c have values assigned or you will see the values instead. To illustrate, you can make the assignments like this:

ClearAll[a, b, c, list1, list2];

list1 = {a, b, c};
list2 = {10, 20, 30};

Evaluate[list1] = list2;


And you can confirm them:

?list1


Globallist1

list1={a,b,c}

?a


Globala

a=10

But when you retrieve the value of list1 you get {10, 20, 30} because a, b, and c evaluate.

Previously I wrote step to conveniently recover such intermediate definitions.

step[list1]

 {a, b, c}


This is wrapped in HoldForm to display these symbols without further evaluation, as can be seen with:

step[list1] // InputForm

HoldForm[{a, b, c}]

-