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


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

Re: Changing a list with the information of other

Started byBob Hanlon <hanlonr357@gmail.com>
First post2013-07-03 08:47 +0000
Last post2013-07-03 08:47 +0000
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Changing a list with the information of other Bob Hanlon <hanlonr357@gmail.com> - 2013-07-03 08:47 +0000

#15096 — Re: Changing a list with the information of other

FromBob Hanlon <hanlonr357@gmail.com>
Date2013-07-03 08:47 +0000
SubjectRe: Changing a list with the information of other
Message-ID<kr0oep$3df$1@smc.vnet.net>
list1 = {{0, 1}, {1, w}, {2, 1 + w}, {3, 1 + 2 w},
   {4, 2}, {5, 2 w}, {6, 2 + 2 w}, {7, 2 + w}};


list2 = {1, 1 + w, 2 + w, 2 w, 2, 2 + 2 w, 1 + 2 w, w};


list1[[Cases[
   Position[list1, #, {2}] & /@ list2,
   {x_, 2} :> x, 2], 1]]


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



Bob Hanlon




On Tue, Jul 2, 2013 at 12:46 AM, Joaquim Nogueira <jen@fct.unl.pt> wrote:

> Good morning
>
> I have the following (possibly very simple) problem.
> I have a list, created using a Table
>
> {{0, 1}, {1, w}, {2, 1 + w}, {3, 1 + 2 w}, {4, 2}, {5, 2 w}, {6, 2 + 2 w},
> {7, 2 + w}}.
>
> Then, using another Table, I created the list
>
> {1, 1 + w, 2 + w, 2 w, 2, 2 + 2 w, 1 + 2 w, w}
>
> Note that all these elements appear always in second place, in the ordered
> pairs of the first list. What I want is an instruction that allows to
> replace all these elements by the ones that appear first in the ordered
> pairs above. That is, I would like to replace this list by the new one
>
> {0, 2, 7, 5, 4, 6, 3, 1}.
>
> As you may guess this is only of interest when the lists are very big
> (with thousands of elements).
>
> Thank you
>
>

[toc] | [standalone]


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


csiph-web