MathGroup Archive 2010

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

Search the Archive

Re: Generalizing Complement to handle multiple occurrences

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112449] Re: Generalizing Complement to handle multiple occurrences
  • From: Christoph Lhotka <christoph.lhotka at univie.ac.at>
  • Date: Thu, 16 Sep 2010 05:58:02 -0400 (EDT)

Hello,

for 1 000 000 random elements on my computer a factor 3 slower than the 
built in Complement function:

a = RandomInteger[{1, 100}, 1000000];
b = RandomInteger[{30, 70}, 1000000];

DeleteCases[a, Alternatives@@Union[b]]

Ciao,

Christoph

On 15/09/2010 10:38, Mark Coleman wrote:
> Greetings,
>
> I'm wondering how one can efficiently generalize the built-in
> Complement function to return multiple occurrences of elements. For
> instance, the current version generates
>
> a={1,2,2,3,4,4,4,4}
> b={3,5,7}
>
> Complement[a,b]={1,2,4}
>
> I'm looking for a way to define
>
> myComplement[a,b]={1,2,2,4,4,4,4}
>
> My current code is very inefficient!
>
> Thanks,
>
> Mark
>
>
>    



  • Prev by Date: How to mimic the Bold menu command
  • Next by Date: Plotting Quartic Solutions in Polar Coordinates
  • Previous by thread: How to mimic the Bold menu command
  • Next by thread: Re: Generalizing Complement to handle multiple occurrences