Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10726 > unrolled thread

Re: how to make a list of rules with 2 other lists composed by different kinds of elements

Started byBill Rowe <readnews@sbcglobal.net>
First post2012-07-01 06:08 +0000
Last post2012-07-01 06:08 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: how to make a list of rules with 2 other lists composed by different kinds of elements Bill Rowe <readnews@sbcglobal.net> - 2012-07-01 06:08 +0000

#10726 — Re: how to make a list of rules with 2 other lists composed by different kinds of elements

FromBill Rowe <readnews@sbcglobal.net>
Date2012-07-01 06:08 +0000
SubjectRe: how to make a list of rules with 2 other lists composed by different kinds of elements
Message-ID<jsopgm$t5$1@smc.vnet.net>
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}

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web