Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Complement replacement

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58615] Re: [mg58608] Complement replacement
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 10 Jul 2005 16:51:33 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

pp=Table[Random[Integer,{1,1000}],{1000}];

r=Range[1000];

Timing[Length[c1=
      Complement[r,pp]]]

{0.000934 Second,368}

Timing[Length[c2=
      Select[r,!MemberQ[pp,#]&]]]

{0.39567 Second,368}

Timing[Length[c3=
      Cases[r,_?(!MemberQ[pp,#]&)]]]

{0.401009 Second,368}

Timing[Length[c4=
      DeleteCases[r,_?(MemberQ[pp,#]&)]]]

{0.401319 Second,368}

c1==c2==c3==c4

True


Bob Hanlon

> 
> From: konstantpi at mail15.com
To: mathgroup at smc.vnet.net
> Date: 2005/07/10 Sun AM 05:12:22 EDT
> Subject: [mg58615] [mg58608] Complement replacement
> 
> 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
> 
> 


  • Prev by Date: Re: Complement replacement
  • Next by Date: Re: Mathematica: how to set the format of binary numbers in plotting?
  • Previous by thread: Re: Complement replacement
  • Next by thread: Re: Complement replacement