MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4018] Re: [mg3881] Lists
  • From: brucec (Bruce Carpenter)
  • Date: Mon, 20 May 1996 02:13:06 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

>        I have a two dimensional list (i.e. {{1, 23}, {2, 24}, {3, 25},
>{4, 26}}), and I want to remove all the first values in each pair of
>numbers.  For instance, for the first pair, I want it to read {23}, and
>for the second, {24} instead of {2, 24}.
>        Any help would be greatly appreciated.
>
>-Alex Bates

Hi Alex:

Here are a few ways to do it (there are certainly more ;-)

In[46]:=
test = {{1, 23}, {2, 24}, {3, 25}, {4, 26}}
Out[46]=
{{1, 23}, {2, 24}, {3, 25}, {4, 26}}
In[47]:=
Rest /@ test
Out[47]=
{{23}, {24}, {25}, {26}}
In[48]:=
Transpose[{Transpose[test][[2]]}]
Out[48]=
{{23}, {24}, {25}, {26}}
In[49]:=
test /. {_,x_} -> {x}
Out[49]=
{{23}, {24}, {25}, {26}}

Cheers,
Bruce Carpenter

-----------------------
Bruce Carpenter
Courseware Coordinator         phone: (217) 398-0700
Wolfram Research, Inc.           fax: (217) 398-0747
100 Trade Centre Drive         email: brucec at wolfram.com
Champaign, IL  61820             web:  http://www.wolfram.com



==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: fourier,units
  • Next by Date: Re: Lists
  • Previous by thread: Re: Lists
  • Next by thread: Re: Lists