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


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

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

From DrMajorBob <btreat1@austin.rr.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to remove the Null character in a Table?
Date 2012-01-17 08:39 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jf3c3o$nfn$1@smc.vnet.net> (permalink)
References <201201162211.RAA15417@smc.vnet.net>

Show all headers | View raw


Table[If[i < 3, i, Sequence[]], {i, 5}] /. Null :> Sequence[]

{1, 2}

DeleteCases[Table[If[i < 3, i, Sequence[]], {i, 5}], Null]

{1, 2}

First@Last@Reap@Table[If[i < 3, Sow@i], {i, 5}]

{1, 2}

First@Last@Reap@Table[i < 3 && Sow@i, {i, 5}]

{1, 2}

Table[If[i < 3, i], {i, 2}]

{1, 2}

Bobby

On Mon, 16 Jan 2012 16:11:34 -0600, Rex <aoirex@gmail.com> 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?
>


-- 
DrMajorBob@yahoo.com

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


Thread

Re: How to remove the Null character in a Table? DrMajorBob <btreat1@austin.rr.com> - 2012-01-17 08:39 +0000

csiph-web