MathGroup Archive 2007

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

Search the Archive

Re: Selecting Rows Where All Columns Satisfy a Condition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82643] Re: Selecting Rows Where All Columns Satisfy a Condition
  • From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
  • Date: Fri, 26 Oct 2007 05:36:17 -0400 (EDT)
  • References: <ffppu6$l6g$1@smc.vnet.net>

Here is an example that does what you want:

m = RandomInteger[{-9, -5}, {100, 4}];
Select[m, FreeQ[#, -9] &]

The function FreeQ[#,-9]& tests # to see whether it is free of any 
subexpression that is -9.

-- 
Steve Luttrell
West Malvern, UK


"Gregory Lypny" <gregory.lypny at videotron.ca> wrote in message 
news:ffppu6$l6g$1 at smc.vnet.net...
> Hello everyone
>
> I've got an Nx4 numeric array called X.  I'd like to pull out all
> rows where -9 does not appear in any of the four columns.  I know I
> can this:
>
> Select[X, #[[1]] != -9 && #[[2]] != -9 && #[[3]] != -9 && #[[4]] !=
> -9 &]
>
> But is there a more elegant way that applies the not-equal-to
> condition to each column without having to repeat it?
>
> Regards,
>
> Gregory
> 



  • Prev by Date: Re: binomial sum bug
  • Next by Date: Re: FullSimplify in functions
  • Previous by thread: Re: Selecting Rows Where All Columns Satisfy a Condition
  • Next by thread: Re: Selecting Rows Where All Columns Satisfy a Condition