Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: how to make a list of rules with 2 other lists composed by different kinds of elements
Replies: 2   Last Post: Jul 1, 2012 2:10 AM

 Messages: [ Previous | Next ]
 Bill Rowe Posts: 1,647 Registered: 3/14/08
Re: how to make a list of rules with 2 other lists composed by different kinds of elements
Posted: Jul 1, 2012 2:08 AM

On 6/30/12 at 5:17 AM, jougraw@gmail.com (Joug Raw) wrote:

>I want to generate a list composed by rules. That is,

>I have two list First one: list1={1, 2, 3} >
>Second one: list2= {"file1", "file2", "file3"}

>What I want is to have a new list like list3= {1 -> "file1", 2
>->"file2", 3 -> "file3"}

In[1]:= list1 = Range[3]

Out[1]= {1,2,3}

In[2]:= list2 = "file" <> ToString@# & /@ list1

Out[2]= {file1,file2,file3}

In[3]:= list3 = Rule @@@ Transpose@{list1, list2}

Out[3]= {1->file1,2->file2,3->file3}

Date Subject Author
6/30/12 Dr.J
7/1/12 Bill Rowe
7/1/12 nanobio9