Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15110
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail |
|---|---|
| From | Bill Rowe <readnews@sbcglobal.net> |
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Changing a list with the information of other |
| Date | Wed, 3 Jul 2013 08:51:04 +0000 (UTC) |
| Sender | steve@smc.vnet.net |
| Approved | Steven M. Christensen <steve@smc.vnet.net>, Moderator |
| Message-ID | <kr0olo$3ee$1@smc.vnet.net> (permalink) |
| Lines | 46 |
| Organization | Time-Warner Telecom |
| NNTP-Posting-Date | 03 Jul 2013 08:53:03 GMT |
| NNTP-Posting-Host | dd7bedb9.news.twtelecom.net |
| X-Trace | DXC=ZH4in?m><TlcJhQ<W;:kglC_A=>8kQj6mMOj3YM9`=ah9SK?DjA;l2iEFiONJ7[GofZV4Z:n\W^[e |
| X-Complaints-To | abuse@twtelecom.net |
| X-Received-Bytes | 2015 |
| Xref | csiph.com comp.soft-sys.math.mathematica:15110 |
Show key headers only | View raw
On 7/2/13 at 12:46 AM, jen@fct.unl.pt (Joaquim Nogueira) wrote:
>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}.
You have indicated your desired output is just the first element
of the first list. You can get this a number of different ways.
Here are two:
In[4]:= a = {{0, 1}, {1, w}, {2, 1 + w}, {3, 1 + 2 w}, {4, 2}, {5,
2 w}, {6, 2 + 2 w}, {7, 2 + w}};
In[5]:= a[[All, 1]]
Out[5]= {0,1,2,3,4,5,6,7}
In[6]:= First /@ a
Out[6]= {0,1,2,3,4,5,6,7}
And if the second list is stored in say b, i.e., b={1, 1 + w, 2
+ w, 2 w, 2, 2 + 2 w, 1 + 2 w, w};
then doing:
b=First/@a; or
b=a[[All,1]];
Replaces what was b with the desired output
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Changing a list with the information of other Bill Rowe <readnews@sbcglobal.net> - 2013-07-03 08:51 +0000
csiph-web