MathGroup Archive 2012

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

Search the Archive

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


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?