0
$\begingroup$

I have failed in adapt the methods discussed in

$\qquad$Pass function or formula as function parameter

to my work.

I would like to know if there is a way to say the following to Mathematica:

If x (global) has been assigned a value, put this value in a new variable, clear x and then later reassign the first value to x.

$\endgroup$
1
  • 2
    $\begingroup$ Block combined with a localized temp variable? $\endgroup$ Oct 24, 2016 at 12:51

1 Answer 1

1
$\begingroup$

What you are proposing is just a private but awkward implementation of Block. Keep in mind, that Block is not a function for organizing code into lexical blocks. In Mathematica, Module does that. Block is for dynamically establishing a new scoping environment; i.e., it blocks assignments in enclosing scopes from being seen the scopes it encloses.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.