Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4759
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Visibility of value of variable bindings in module |
| Date | 2011-09-05 11:22 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j42bd5$rts$1@smc.vnet.net> (permalink) |
On 9/4/11 at 6:05 PM, cawright.99@gmail.com (caw) wrote:
>Module[{x = Sum[i, {i, Length[{1, 2, 3}]}], y = x + 1}, Print[y];
>Print[x]]
>prints out:
>1 + x
>6
>So, in the variable declaration section of the Module statement, the
>binding of x to 6 isn't visible to y. (It's a bit like let and let*,
>but not)
>Is there a form which will allow the bindings to be visible within
>the variable declaration section?
Not using Module. But clearly you could do
Module[{x = Sum[i, {i, Length[{1, 2, 3}]}], y}, y = x + 1; Print[y];
Print[x]]
7
6
Or you could use Block instead of Module
Block[{x = Sum[i, {i, Length[{1, 2, 3}]}], y = x + 1}, Print[y];
Print[x]]
7
6
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Visibility of value of variable bindings in module Bill Rowe <readnews@sbcglobal.net> - 2011-09-05 11:22 +0000
csiph-web