MathGroup Archive 1997

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

Search the Archive

Re: Complement

Houshou Chen <houshou at>
[mg6100] Complement

> The result of Complement always resort the order, Is there any code
> such that  taking the complement without changing the original
> order?
> Complement[{5,4,3,2,1},{1,2}] is {3, 4, 5}, I would like the result
> to be {5,4,3} instead.


DeleteCases[{5,4,3,2,1}, Alternatives@@{1,2}]

	{5, 4, 3}
Because Alternatives@@{1,2} becomes Alternatives[1,2] we can work  
with lists as inputs.

Allan Hayes
hay at

  • Prev by Date: Re: Complement
  • Next by Date: Version of Mathematica
  • Previous by thread: Re: Complement
  • Next by thread: Version of Mathematica