Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Why Return[] does not work?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109502] Re: Why Return[] does not work?
  • From: image_doctor <eep1mp at googlemail.com>
  • Date: Sat, 1 May 2010 06:51:25 -0400 (EDT)
  • References: <hr6ihp$2f8$1@smc.vnet.net>

> 2) is there better way to implement intersection check?


You could try this relatively elegant solution ....

IntersectQ[a_, a_] := True
IntersectQ[a_, b_] := False


With the following  timing results.

n=100000000;
r1 = RandomInteger[{1,5},{n}];
r2 = RandomInteger[{1,5},{n}];
r3=r1;

Timing[IntersectQ[r1,r1]]
Timing[IntersectQ[r1,r2]]
Timing[IntersectQ[r1,r3]]
Out[55]= {0.,True}
Out[56]= {0.,False}
Out[57]= {0.,True}



  • Next by Date: Re: How to disable Integrate[] ?
  • Next by thread: Re: Why Return[] does not work?