Re: Selecting Lists Without Null Results

• To: mathgroup at smc.vnet.net
• Subject: [mg69032] Re: Selecting Lists Without Null Results
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sun, 27 Aug 2006 01:24:07 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <ecooe1\$2qr\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Gregory Lypny wrote:
> 	I must be doing something wrong as usual.  How come I can select
> list with elements that have the word Null in them as a result of a
> computation, but I cannot exclude them?
>
> I have an array called runsTable with 179 rows, and there are five
> rows with Null in column 14.
>
> So,
>
> 	Length[Select[runsTable, #[[14]] == Null &]
>
> returns 5.
>
> But
>
> 	Length[Select[runsTable, (#[[14]]Â¬ Null) &]]
>
> returns 0 when it should return 174, that is, 179 minus 5.
>
> 	Am I using the NOT operator incorrectly?
>
> 	Regards,
>
> 		Gregory
>
Hi Gregory,

Although I do not have any explanation about the behavior of your
expression with the Not function, you could achieve the intended feature
by using the DeleteCases function as in In[3]:

In[1]:=
runsTable=Table[If[(n=Random[])â?¤9/10,n , Null],{10},{5}]

Out[1]=
{{0.49539, 0.316524, 0.664504, 0.103548, 0.492748},

{0.70693, 0.124625, 0.439284, 0.338863, 0.434249},

{0.0211921, 0.250494, 0.590875, 0.504541, Null},

{0.447929, 0.500307, 0.877769, 0.26441, 0.665427},

{0.512114, 0.565924, Null, Null, 0.0167236},

{0.2494, 0.240872, 0.807139, 0.523975, 0.54247},

{0.116247, 0.367855, 0.185113, 0.108221, 0.0950553},

{0.117361, 0.594238, 0.603679, 0.113885, 0.669432},

{0.0939308, 0.72591, 0.849475, 0.00400574,

0.581817}, {0.159987, Null, 0.0933188, 0.565094,

Null}}

In[2]:=
Length[Cases[runsTable,x_/;x[[5]]==Null]]

Out[2]=
2

In[3]:=
Length[DeleteCases[runsTable,x_/;x[[5]]==Null]]

Out[3]=
8

Regards,
Jean-Marc

```

• Prev by Date: Re: Graphics--If condition in Plot3D?????????
• Next by Date: Re: Selecting Lists Without Null Results
• Previous by thread: Re: Selecting Lists Without Null Results
• Next by thread: Re: Selecting Lists Without Null Results