Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7924

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

From Tomas Garza <tgarza10@msn.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to remove the Null character in a Table?
Date 2012-01-17 08:44 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jf3ce9$njj$1@smc.vnet.net> (permalink)
References <201201162211.RAA15417@smc.vnet.net>

Show all headers | View raw


Sounds a little farfetched, but this is a nice example to introduce the use of Sow and Reap:
In[1]:= Reap[Sow[#, # < 3] & /@ Table[i, {i, 5}], True][[2, 1]]
Out[1]= {1, 2}
Something simpler might be
In[3]:= Cases[Table[If[i < 3, i,], {i, 5}], _?NumberQ]
Out[3]= {1, 2}
or even simpler
In[7]:= Select[Table[If[i < 3, i,], {i, 5}], NumberQ[#] &]
Out[7]= {1, 2}
-Tomas



> Date: Mon, 16 Jan 2012 17:11:34 -0500
> From: aoirex@gmail.com
> Subject: How to remove the Null character in a Table?
> To: mathgroup@smc.vnet.net
>
> 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?
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: How to remove the Null character in a Table? Tomas Garza <tgarza10@msn.com> - 2012-01-17 08:44 +0000

csiph-web