Re: Complement replacement

*To*: mathgroup at smc.vnet.net*Subject*: [mg58632] Re: Complement replacement*From*: Bill Rowe <readnewsciv at earthlink.net>*Date*: Sun, 10 Jul 2005 16:51:59 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

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