MathGroup Archive 2012

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

Search the Archive

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


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?