Re: Variables within With statement
- To: mathgroup at smc.vnet.net
- Subject: [mg123730] Re: Variables within With statement
- From: markholtuk <markholtuk at googlemail.com>
- Date: Sat, 17 Dec 2011 02:39:12 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jccg39$mb4$1@smc.vnet.net>
You could try delaying assignment of a, as follows: In[1]:= With[{a := a = 5, b = 10 a}, a + b] Out[1]= 55 Cheers, Mark On Dec 15, 9:53 am, "Harvey P. Dale" <h... at nyu.edu> wrote: > Is there any easy way to have one variable within a With > statement take its value from a prior variable in the same With > statement? For example, if I evaluate With[{a = 5, b = 10 a}, a + b], I > get 5 + 10a, and what I want is 55. I can get there like this: With[{a > = 5}, With[{b = 10 a}, a + b]] -- which does produce 55 -- but it would > be nicer if I could use a single With statement and get b, within it, to > take its value from a. > > Thanks. > > Harvey