Re: how to make a list of rules with 2 other lists composed by different kinds of elements
- To: mathgroup at smc.vnet.net
- Subject: [mg127115] Re: how to make a list of rules with 2 other lists composed by different kinds of elements
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sun, 1 Jul 2012 02:07:30 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
On 6/30/12 at 5:17 AM, jougraw at 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}