Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 17
From: Taiwan
Registered: 3/11/12
Re: how to make a list of rules with 2 other lists composed by
Posted: Jul 1, 2012 2:10 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Joug Raw=E6=96=BC 2012=E5=B9=B46=E6=9C=8830=E6=97=A5=E6=98=9F=E6=9C=9F=E5=
> Dear all,
> I want to generate a list composed by rules. That is,
> I have two list
> First one:
> list1={1, 2, 3}
> The elements of this list are Integers.
> Map[Head, list1] = {Integer, Integer, Integer}
> Second one:
> list2= {"file1", "file2", "file3"}
> The elements of this list are Strings.
> Map[Head, list2] = {String, String, String}
> What I want is to have a new list like
> list3= {1 -> "file1", 2 -> "file2", 3 -> "file3"}
> Map[Head, list3] = {Rule, Rule, Rule}
> Yes, of cause I can generate a list of rule manually. But what I have are
> two big list of many elements and they are the output of other codes. So,
> in real life this would be a part of big program. That is why I want to
> generate the rule list automatically from list1 and list2. How could I do
> this in a simple way? Thank you for your help.
> Best regards,
> Joug

Hi, the example you posted was so simple that the solution should be as simple as
list3 = Inner[ Rule, list1, list2, List ]
But if you are actually talking about more complicated cases, please tell us more about the difficulties you had.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.