MathGroup Archive 1999

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

Search the Archive

Re: Parts of a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15457] Re: Parts of a list
  • From: Rolf Mertig <rolf at mertig.com>
  • Date: Mon, 18 Jan 1999 04:21:58 -0500
  • Organization: Mertig Research & Consulting
  • References: <77jkve$304@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hossein Kazemi wrote:
> 
> 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.
> 
> Thanks for your help.
> 
> Hossein Kazemi
> UMass
> kazemi at som.umass.edu

In[1]:=  x={{1,0},{2.5, .5},{3,0},{0,2}};

In[2]:= Select[x, MatchQ[#, {_,a_/;a=!=0}]&]

Out[2]= {{2.5, 0.5}, {0, 2}}

In[3]:= Cases[x, {_, a_/;a=!=0}]

Out[3]= {{2.5, 0.5}, {0, 2}}


-- 

Rolf Mertig
Mertig Research & Consulting  
Mathematica training and programming Development and distribution of
FeynCalc  Amsterdam, The Netherlands
http://www.mertig.com


  • Prev by Date: Re: Parts of a list
  • Next by Date: Re: Data fitting with Mathematica 3.0
  • Previous by thread: Re: Parts of a list
  • Next by thread: Re: Parts of a list