Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7304

Re: Variables within With statement

From Shizu <slivo.vitz@msa.hinet.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Variables within With statement
Date 2011-12-17 07:48 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jchhgk$ih2$1@smc.vnet.net> (permalink)

Show all headers | View raw


In Block[], global variables have local values.
So, this will work:

  Clear[a];
  Block[{a = 5, b = 10 a}, a + b]


In With[], rhs of an assignment(eg., 10 a) is evaluated before With[] as a whole.
So, b = 10 a, and a's value is global.
And so, this doesn't work for your case:

  Clear[a];
  With[{a = 5, b = 10 a}, a + b]

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Variables within With statement Shizu <slivo.vitz@msa.hinet.net> - 2011-12-17 07:48 +0000

csiph-web