Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.4K Views
|
16 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Trouble understanding the local variables of the Block command

I'm having trouble understanding the local variables of the Block command. Thanks for your attention

(*example one*)
(*This is said in the documentation*)
(*Blocklocalizes values only;it does not create new symbols*)
(*I don't understand the previous sentence*)
ClearAll["Global`*"];
Block[{x}, x]
Block[{x}, Print[x]]

(*example two*)
(*This is an example of the documentation.*)
(*But if one of x or y is global the example does not work*)

ClearAll["Global`*"];
Block[{f = Sin[x + I y]},  ParametricPlot[Evaluate[{Re[f], Im[f]}], {x, -Pi, Pi}, {y, -2, 2},   Mesh -> 10]]

(*example three*)
(*I would like the block to work regardless of whether x is global or not*)

ClearAll["Global`*"];
Block[{x},
 TraditionalForm@TextCell[Column[{
     Row[{x, " = ", 5}]    (*I want x to always be a symbol*)
     }, Spacings -> 0.5], "Text", FontFamily -> "Palatino",    FontSize -> 18]
 ]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use