Timeline for How to replace a variable that was assigned a value before
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 23, 2013 at 9:04 | vote | accept | sjdh | ||
May 22, 2013 at 11:27 | history | edited | Ajasja | CC BY-SA 3.0 |
added link
|
May 22, 2013 at 10:30 | history | edited | Albert Retey | CC BY-SA 3.0 |
added 23 characters in body
|
May 22, 2013 at 10:28 | comment | added | Albert Retey |
@bills: when you start to write code which you or even others try to reuse, then it is in general best to try to make as few changes to the global state of your session as possible. If you e.g. call a function which clears certain global variables with Clear that might not be what the caller expects and break the callers session/code. When writing packages and making use of name spaces, you also might need to take extra care to Clear the correct symbols.
|
|
May 22, 2013 at 10:23 | history | edited | Albert Retey | CC BY-SA 3.0 |
added some remarks and examples
|
May 22, 2013 at 10:21 | comment | added | Albert Retey | @Mr. Wizard: good point, it is somewhat more elegant, but as I have now added, it also is somewhat less explicit about how exactly it changes the evaluation order. Not a problem if you have a firm grasp of it, as I guess is the case for you :-). I added it to my answer... | |
May 22, 2013 at 10:20 | comment | added | bill s | Can someone explain to me why this is useful? What I always have a tendency to do is to Clear[f] or Clear[f,x] and then there's nothing to worry about. What is the advantage of the more sophisticated approaches? | |
May 22, 2013 at 10:13 | comment | added | Mr.Wizard |
I usually use: Unevaluated[x + 1] /. HoldPattern[x] -> y
|
|
May 22, 2013 at 10:07 | history | answered | Albert Retey | CC BY-SA 3.0 |