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: [mg109489] Re: Why Return[] does not work?
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Thu, 29 Apr 2010 02:54:32 -0400 (EDT)
  • References: <hr6ihp$2f8$1@smc.vnet.net> <hr8isl$55h$1@smc.vnet.net> <hr94fk$e4c$1@smc.vnet.net>

Dims wrote:
> On 28 =D0=B0=D0=BF=D1=80, 09:59, "M.Roellig" <markus.roel... at googlemail.com>> wrote:
> 
>> In[2]:= Intersection[{a, b}, {c, a}] =!= {}
> 
> But would Mathematica optimize evaluation of this expression, i.e.,
> terminate searching for common elements if one already found?
> 
It would not terminate searching early because the result was being 
compared with {}, but it would probably be more efficient anyway because:

a) It would sort the two lists to make the intersection process more 
efficient.

b) There is an overhead to each Mathematica step, so that using a 
built-in operation is usually more efficient than coding your own - but 
if in doubt, you can always check using Timing. It is this overhead that 
makes functional operations more efficient, because they just take fewer 
steps.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: NDSolve: ..numerically ill-conditioned...
  • Next by Date: Re: Sphere formula
  • Previous by thread: Re: Why Return[] does not work?
  • Next by thread: Re: Why Return[] does not work?