MathGroup Archive 2010

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

Search the Archive

Re: Why Return[] does not work?


> 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?