       Re: Occurrences in Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg106403] Re: Occurrences in Mathematica
• From: Ray Koopman <koopman at sfu.ca>
• Date: Mon, 11 Jan 2010 18:52:45 -0500 (EST)
• References: <hic33o\$59f\$1@smc.vnet.net>

```On Jan 10, 12:28 am, George <gtatishv... at gmail.com> wrote:
> Hi,
>
> I have a very big list of elements and I need Mathematica to give me
> only those elements which occure only once...
>
> Could anybody advise me please how to write the code for that?
>
> Thks much
> George

It takes longer for Cases to process the Tally result
than it takes Tally to generate it. Pick is faster.

In:= Timing@Length[a = RandomInteger[999999,1*^6]]
Out= {0.05,1000000}

In:= Timing@Length[b = Tally@a]
Out= {1.59,631912}

In:= Timing@Length[c = Cases[b,{x_,1}:>x]]
Out= {1.73,367228}

In:= Timing@Length[d = Pick[Sequence@@Transpose@b,1]]
Out= {0.5,367228}

In:= c === d
Out= True

```

• Prev by Date: Re: Rotate
• Next by Date: Problem: InverseLaplaceTransform with unexpected result
• Previous by thread: Re: Occurrences in Mathematica