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: [mg124336] Re: How to remove the Null character in a Table?
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 17 Jan 2012 03:25:33 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201201162211.RAA15417@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

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 at 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 at yahoo.com



  • Prev by Date: Re: opposite of AppendTo
  • Next by Date: Re: How to easily set up all coefficients to be positive in Solving an integer equation?
  • 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?