Re: A ToExpression question
- To: mathgroup at smc.vnet.net
- Subject: [mg58335] Re: [mg58316] A ToExpression question
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Tue, 28 Jun 2005 21:56:35 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
A character embedded in a string is not a symbol. f1[x_]:=Print[x]; f2[x_]:=ToExpression["Print["<>ToString[x]<>"]"]; f3[x_]:=Module[{y=x},ToExpression["Print["<>ToString[y]<>"]"]]; f4[x_]:=Block[{y=x},ToExpression["Print[y]"]]; Scan[#[0]&,{f1,f2,f3,f4}] 0 0 0 0 Bob Hanlon > > From: "Ray Koopman" <koopman at sfu.ca> To: mathgroup at smc.vnet.net > Date: 2005/06/28 Tue AM 05:13:15 EDT > Subject: [mg58335] [mg58316] A ToExpression question > > f1[x_] := Print[x]; > f2[x_] := ToExpression["Print[x]"]; > f3[x_] := Module[{y = x}, ToExpression["Print[y]"]]; > f4[x_] := Block[{y = x}, ToExpression["Print[y]"]]; > > Scan[#[0]&,{f1,f2,f3,f4}] > > 0 > x > y > 0 > > Why don't f2 and f3 print 0 ? > >