Message Boards Message Boards

0
|
3982 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

A few general questions on scope of variables

Posted 7 years ago

1)Is there a way to declare a variable (say, x) to be treated as real during your Mathematica session in entire notebook?

2) The command Clear[symbol,...] clears Global variables or not? If not is it a way to clear all variables (Global as well)

3) Is there a command to clear all variables without naming them?

Many thanks

JME

POSTED BY: Javad Emami
  1. Some functions accept Assumptions, for those cases you could add to $Assumptions something like Element[x, Reals].

  2. You can try it out:

fdfasda

x = 3
ff[a_] := Module[{},
  Clear[x];
  Print[a]
  ]
ff[1]
x

So yes, it does. I'm not sure how this interacts with namespaces, but can surely be found here: guide/NamespaceManagement

  1. You could use Clear or ClearAll

To do something like:

ClearAll[Evaluate[Context[] <> "*"]]
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract