Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*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 2000

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

Search the Archive

Re: Cases, Throw, and Catch

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24220] Re: Cases, Throw, and Catch
  • From: Mark Fisher <me.fisher at atl.frb.org>
  • Date: Sat, 1 Jul 2000 03:21:51 -0400 (EDT)
  • Organization: Federal Reserve Bank of Atlanta
  • References: <8jeaq0$jd4@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Oops! Thanks to those who were kind enough to respond to me privately
and not ridcule me in public. Here is a less-stupid use of Catch and
Throw with Cases. However,
the Catch/Throw version is slower, which makes sense to me. 

In[129]:=
xtab = Table[x, {10^6}];

In[138]:=
Catch[Cases[xtab, x :> Throw[{x}]]] // Timing

Out[138]=
{1.25 Second, {x}}

In[139]:=
Cases[xtab, x, 1, 1] // Timing

Out[139]=
{0.172 Second, {x}}

In[140]:=
ytab = {xtab, y};

In[141]:=
Catch[Cases[ytab, x :> Throw[{x}], Infinity]] // Timing

Out[141]=
{1.25 Second, {x}}

In[142]:=
Cases[ytab, x, Infinity, 1] // Timing

Out[142]=
{0.171 Second, {x}}

--Mark.


  • Next by Date: Re: exponents when changing from 3.0 to 4.0
  • Next by thread: Re: exponents when changing from 3.0 to 4.0