MathGroup Archive 2008

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

Search the Archive

List complement operator

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84950] List complement operator
  • From: zac <replicatorzed at gmail.com>
  • Date: Mon, 21 Jan 2008 04:06:27 -0500 (EST)

Dear group,

I'm loooking for an elegant and efficient way to subtract a list (not
a set) from an other one.

a = {1, 1, 1, 2, 3, 3, 4, 5, 5, 5, 2, 6, 7, 7};
b = {1, 2, 2, 3, 4, 7, 8};

Complement[a,b] returns {5, 6}, as expected. However I would like to
treat each entry as a discrete element, therefore my target result is:
{1, 1, 3, 5, 5, 5, 6, 7}. Union can not be used, although Sort  is
allowed (ie. whether the result is sorted or not is of no concern).
Any idea?

Istvan Zachar


  • Prev by Date: Fonts in Mathematica 6.0
  • Next by Date: Re: Mathematica 6.01 kernel crash report. reproducible. C++
  • Previous by thread: Re: Fonts in Mathematica 6.0
  • Next by thread: Re: List complement operator