Re: Defining a function in module problem?
- To: mathgroup at smc.vnet.net
- Subject: [mg45999] Re: Defining a function in module problem?
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Mon, 2 Feb 2004 05:20:41 -0500 (EST)
- References: <bvhpvs$8dh$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
a[x_]:=Module[{f,g},g=z/3;f=Function[z,Evaluate[g]];f[x]];
a[1]
z/3
The z in the definition of g is in a global context and the z in the definition
of f is in a local context. They are different. Using only the local context
a[x_]:=Module[{f},f=Function[z,z/3];f[x]];
a[1]
1/3
Which would actually be written
a[x_] := x/3;
Bob Hanlon
In article <bvhpvs$8dh$1 at smc.vnet.net>, jflanigan at netzero.net (jose flanigan)
wrote:
<< why does this
a[x_] := Module[{f, g}, g = z/3; f = Function[z, Evaluate[g]]; f[x]]
produce
a[1] = z/3
instead of
a[1]=1/3
I don't understand the philosophy here.