Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: What determines what is assigned to Out[]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80319] Re: What determines what is assigned to Out[]?
  • From: Bill Rowe <readnewsciv at sbcglobal.net>
  • Date: Fri, 17 Aug 2007 01:54:19 -0400 (EDT)

On 8/16/07 at 7:20 AM, andrew.j.moylan at gmail.com (Andrew Moylan)
wrote:

>I am starting to see a pattern here. Can anyone explain the exact
>rule that determines what gets assigned to the Out[] variable?

>This is important because, for example, compare the following fairly
>equivalent pieces of code:

>Module[{}, m = RandomReal[1, 10000000]; flag = 1;]

>Module[{}, flag = 1; m = RandomReal[1, 10000000];]

>The former assigns 1 to Out[], whereas the latter assigns a roughly
>80MB lump of random reals to Out[]!

Right. Unless you specifically direct otherwise in you code,
Module returns the value of the last statement executed. This is
no different than doing:

In[8]:= RandomReal[1, 10];
flag = 1;
%

Out[10]= 1

In[11]:= flag = 1;
RandomReal[1, 10];
%

Out[13]= {0.972967,0.535982,0.116394,0.315125,0.593156,0.621663,0.\
0665424,0.124622,0.785656,0.329686}

outside of Module. In fact, there is essentially no advantage to
using the construct, Module[{},... If no variables are included
in the first argument, there will be no local variables and
Module has essentially no effect on the results.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Using debugger in Mathematica 6 ?
  • Next by Date: generalized 2d IFS for D_n Cartan group using MathWorld DihedralGroupMatrices
  • Previous by thread: Re: What determines what is assigned to Out[]?
  • Next by thread: Re: What determines what is assigned to Out[]?