MathGroup Archive 2011

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

Search the Archive

Re: Variables within With statement

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123813] Re: Variables within With statement
  • From: Szabolcs <szhorvat at gmail.com>
  • Date: Tue, 20 Dec 2011 03:06:05 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jccg39$mb4$1@smc.vnet.net> <jchh07$i99$1@smc.vnet.net>
  • Reply-to: comp.soft-sys.math.mathematica at googlegroups.com

On Saturday, 17 December 2011 08:39:51 UTC+1, markholtuk  wrote:
> You could try delaying assignment of a, as follows:
> 
> In[1]:= With[{a := a = 5, b = 10 a}, a + b]
> 
> Out[1]= 55
> 

Please note that this solution modifies the global variable 'a', and therefore defeats the purpose of With (which is defining *local* constants).

The original question is a good one, I often wish for such a functionality too (and it's no coincidence that so many custom implementations can be found all over the web).



  • Prev by Date: Fourier Cos transform
  • Next by Date: Re: Printing Mathematica Notebooks and WYSIWYG
  • Previous by thread: Re: Variables within With statement
  • Next by thread: Re: Variables within With statement