MathGroup Archive 2005

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

Search the Archive

Re: Complement replacement


On 7/10/05 at 5:12 AM, konstantpi at mail15.com wrote:

>hi in the list: pp=Table[Random[Integer, {1, 1000}], {i, 1000}];
>how could i know which numbers from 1 to 1000 does not exist in the
>pp List. but without using: Complement[Table[i,{i,1000}],pp]
>regards

You could use

Complement[Range@1000,pp]

which is probably a bit more efficient. And if you wanted you could find ways to achieve the same result without using Complement. For example,

Split[Union@pp,#2-#1&]

will group the set of numbers into blocks of contiguous integers. The missing integers could be found by looking at the last value of a block and the first value of the next block. But this is undoubtedly more computation than simply using Complement with Range as above.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Complement replacement
  • Next by Date: Re: Complement replacement
  • Previous by thread: Re: Complement replacement
  • Next by thread: Re: Complement replacement