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

MathGroup Archive 2013

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

Search the Archive

Function with optional default argument cannot cache results

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130670] Function with optional default argument cannot cache results
  • From: Dan O'Brien <danobrie at gmail.com>
  • Date: Wed, 1 May 2013 03:37:54 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

Is there a discussion somewhere on why this is?

In[1]:= $Version
f[x_, y_: 2] := f[x, y] = {Pause[1], x, y}
f[1, 2] // AbsoluteTiming
f[1, 2] // AbsoluteTiming
f[1] // AbsoluteTiming
f[1] // AbsoluteTiming

Out[1]= "9.0 for Microsoft Windows (64-bit) (January 25, 2013)"

Out[3]= {1.014002, {Null, 1, 2}}

Out[4]= {0., {Null, 1, 2}}

Out[5]= {1.029602, {Null, 1, 2}}

Out[6]= {1.014002, {Null, 1, 2}}



  • Prev by Date: Re: Does Wolfram Alpha Pro support all of the functionality of Mathematica
  • Next by Date: Re: NMF in Mathematica 8
  • Previous by thread: Re: Does Wolfram Alpha Pro support all of the functionality of Mathematica
  • Next by thread: Re: Function with optional default argument cannot cache