Re: Parts of a list
- To: mathgroup at smc.vnet.net
- Subject: [mg15478] Re: Parts of a list
- From: Stephen P Luttrell <luttrell at signal.dra.hmg.gb>
- Date: Mon, 18 Jan 1999 04:22:20 -0500
- Organization: Defence Evaluation and Research Agency
- References: <77jkve$304@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
>I have a list (matrix) that looks like this > >x={{1,0},{2.5, .5},{3,0},{0,2}} > >Now I want to eliminate those vectors that have zero for the second >case. That is, I want to get > >{{2.5, .5},{0,2}}. > >Is there a quick way of doing this? >I tried to apply Select to this but could not get it to work. This does the trick: In[1]:=Cases[{{1,0},{2.5, .5},{3,0},{0,2}},{_,_?(#!=0&)}] Out[1]={{2.5,0.5},{0,2}} Stephen P Luttrell Signal Processing and Imagery Department DERA Malvern, St.Andrew's Road Malvern, United Kingdom, WR14 3PS +44 (0)1684 894046 (tel) +44 (0)1684 894384 (fax) luttrell at signal.dera.gov.uk (email)