Re: Lists
- To: mathgroup at smc.vnet.net
- Subject: [mg4023] Re: [mg3881] Lists
- From: "Paul R. Wellin" <wellin at telospub.com>
- Date: Mon, 20 May 1996 02:13:58 -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.
How about this for simplicity. Here is a set of pairs of
integers:
In[3]:= data = Table[Random[Integer,{1,10}],{5},{2}]
Out[3]= {{10, 7}, {1, 8}, {3, 10}, {3, 7}, {1, 4}}
And this replaces each pair with only the second entry:
In[4]:= data /. {a_,b_} -> {b}
Out[4]= {{7}, {8}, {10}, {7}, {4}}
---
Paul Wellin
Editor of Computational Science
TELOS/Springer-Verlag
3600 Pruneridge Avenue, Suite 200
Santa Clara CA 95051 USA
phone: 408-249-9314
fax: 408-249-2595
email: wellin at telospub.com
WWW: http://www.telospub.com/~wellin/
==== [MESSAGE SEPARATOR] ====