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


Groups > comp.soft-sys.math.mathematica > #7882 > unrolled thread

How to remove the Null character in a Table?

Started byRex <aoirex@gmail.com>
First post2012-01-16 12:01 +0000
Last post2012-01-17 08:52 +0000
Articles 5 — 5 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  How to remove the Null character in a Table? Rex <aoirex@gmail.com> - 2012-01-16 12:01 +0000
    Re: How to remove the Null character in a Table? roby <roby.nowak@gmail.com> - 2012-01-17 08:36 +0000
    Re: How to remove the Null character in a Table? David Reiss <dbreiss@gmail.com> - 2012-01-17 08:45 +0000
    Re: How to remove the Null character in a Table? Ray Koopman <koopman@sfu.ca> - 2012-01-17 08:47 +0000
    Re: How to remove the Null character in a Table? "andre.robin3" <andre.robin3@wanadoo.fr> - 2012-01-17 08:52 +0000

#7882 — How to remove the Null character in a Table?

FromRex <aoirex@gmail.com>
Date2012-01-16 12:01 +0000
SubjectHow to remove the Null character in a Table?
Message-ID<jf13je$5ln$1@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?

[toc] | [next] | [standalone]


#7907

Fromroby <roby.nowak@gmail.com>
Date2012-01-17 08:36 +0000
Message-ID<jf3bu1$ne1$1@smc.vnet.net>
In reply to#7882
On 16 Jan., 13:01, Rex <aoi...@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?

trick no.1
Table[If[i < 3, i,], {i, 5}] // DeleteCases[#, Null] &

trick no.2
Table[If[i < 3, i, Sequence@@{}], {i, 5}]

and many other tricks ...

Cheers Robert

[toc] | [prev] | [next] | [standalone]


#7925

FromDavid Reiss <dbreiss@gmail.com>
Date2012-01-17 08:45 +0000
Message-ID<jf3cf7$nk9$1@smc.vnet.net>
In reply to#7882
here's one possibility:

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

--David


On Jan 16, 7:01 am, Rex <aoi...@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?

[toc] | [prev] | [next] | [standalone]


#7929

FromRay Koopman <koopman@sfu.ca>
Date2012-01-17 08:47 +0000
Message-ID<jf3cj2$nm7$1@smc.vnet.net>
In reply to#7882
On Jan 16, 4:01 am, Rex <aoi...@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?

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

{1, 2}

[toc] | [prev] | [next] | [standalone]


#7938

From"andre.robin3" <andre.robin3@wanadoo.fr>
Date2012-01-17 08:52 +0000
Message-ID<jf3crm$nqn$1@smc.vnet.net>
In reply to#7882
Table[If[i < 3, i,], {i, 5}] // DeleteCases[#, Null] &

---> {1,2}

Or :

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

---> {1,2}

"Rex" <aoirex@gmail.com> a écrit dans le message de news: 
jf13je$5ln$1@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?
> 


[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web