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: [mg58616] Re: [mg58608] Complement replacement
  • From: Ken Levasseur <kenneth_levasseur at uml.edu>
  • Date: Sun, 10 Jul 2005 16:51:34 -0400 (EDT)
  • References: <200507100912.FAA06500@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

If you are looking to improve on the speed of Complement, ignore this  
solution.  It's way too slow, but does avoid using Complement.

In[20]:=
pp = Table[Random[Integer, {1, 1000}], {i, 1000}];

In[21]:=
r1 = Complement[Range[1000], pp];

In[22]:=
r2 = Range[1000] //. ({p___, #1, q___} :> {p, q} & ) /@  pp;

In[23]:=
r1 == r2

Out[23]=
True

On Jul 10, 2005, 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
>
>

***********************************
Ken Levasseur
Mathematical Sciences
UML
http://faculty.uml.edu/klevasseur



  • Prev by Date: Re: MultiLink.exe, MultiLinkServer.exe
  • Next by Date: Re: Complement replacement
  • Previous by thread: Complement replacement
  • Next by thread: Re: Complement replacement