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: Changing a list with the information of other
Replies: 7   Last Post: Jul 3, 2013 6:05 PM

Advanced Search

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

Posts: 316
From: Penn State
Registered: 6/20/10
Re: Changing a list with the information of other
Posted: Jul 3, 2013 6:05 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Here is one way:

a = {{0, 1}, {1, w}, {2, 1 + w}, {3, 1 + 2 w}, {4, 2}, {5, 2 w}, {6,
2 + 2 w}, {7, 2 + w}};
b = {1, 1 + w, 2 + w, 2 w, 2, 2 + 2 w, 1 + 2 w, w};

Apply[#1 &,
Flatten[Table[Select[a, #[[2]] == b[[i]] &, 2], {i, 1, b // Length}],
1], 1]

{0, 2, 7, 5, 4, 6, 3, 1}




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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.