Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: How to remove the Null character in a Table?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124353] Re: How to remove the Null character in a Table?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 17 Jan 2012 03:31:27 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 1/16/12 at 5:11 PM, aoirex at gmail.com (Rex) wrote:

>For example,

>Table[If[i < 3, i,], {i, 5}] will give {1, 2, Null, Null, Null}

>But I want the result to be {1,2}.

>Any trick for this?

It is trivial to filter the Null. For example:

In[5]:= Cases[Table[If[i < 3, i], {i, 5}], _?NumericQ]

Out[5]= {1,2}

or simply use code that doesn't generate a Null, i.e.,

In[6]:= Cases[Range[5], _?(# < 3 &)]

Out[6]= {1,2}







  • Prev by Date: Is there any efficient easy way to compare two lists with the same length with Mathematica?
  • Next by Date: Re: How to remove the Null character in a Table?
  • Previous by thread: Re: How to remove the Null character in a Table?
  • Next by thread: Re: How to remove the Null character in a Table?