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$
  • 2
    $\begingroup$ Block combined with a localized temp variable? $\endgroup$ – Marius Ladegård Meyer Oct 24 '16 at 12:51
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, privacy policy and cookie policy

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