Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 12

Questions on assigning and unassigning definitions to names that represent them, including issues raised by context and localization. Use tag [assignment] for issues relating to Set versus SetDelayed.

5
votes
There are significant practical differences. Quit does not "clear" anything, it instead restarts the kernel, i.e. resets it to the default state. There is a lot of internal state that changes during …
answered Apr 1 '16 by Szabolcs
5
votes
You can just package it up into a function: fibcounter[k_Integer?NonNegative] := Block[{fib, count = 0}, fib[0] := (count++; 0); fib[1] := (count++; 1); fib[n_] := (count++; fib[n - 1] + fib[ …
answered Jun 10 '14 by Szabolcs
16
votes
This is because only symbols can be localized by Module. It is not about assignment, but localization. Subscript[a, 1] is not a symbol, but a compound expression, so: Module[{Subscript[a, 1] = "x" …
answered Jan 28 '12 by Szabolcs
8
votes
Indexed variables can be used in symbolic calculations. They're useful when the number of variables used needs to be changed programmatically. Here's an example: vars = Array[a, 3] (* {a[1], a[2], …
answered Jun 3 '14 by Szabolcs
3
votes
You are confusing parallel kernels (subkernels) with the ability to have multiple evaluators set up in the front end. DistributeDefinitions is part of the parallel tools. Mathematica can run code …
answered Nov 14 '16 by Szabolcs
21
votes
You asked for a general explanation instead of just focusing on specific application examples, so here it goes ... The concepts of "pass by reference" and "pass by value" that you may know from langu …
answered Sep 22 '17 by Szabolcs
1
vote
Because the latter is equivalent to {1,2,3,4,5}[[2]] = 0 which is invalid. The former stays as listCopy[[2]] = 0 You can't change (i.e. assign to) parts of a literal like this. You can chang …
answered Aug 5 '14 by Szabolcs
3
votes
The problem is that the definition of CirclePlus is not distributed to parallel kernels. You can test this using DistributeDefinitions[CirclePlus] (* {} *) ParallelEvaluate[Print@Definition[CircleP …
answered Sep 6 '17 by Szabolcs
23
votes
2answers
I have been bitten hard by SaveDefinitions -> True. I'll describe in detail what happened below. My questions are: Is this a bug? What is the most convenient workaround? Consider a definition is …
asked Sep 9 '13 by Szabolcs
5
votes
If I understand it correctly, the gist of your question is going from HoldComplete[x, y, z, up] to HoldComplete[1, y^2, z, up] assuming the following definitions: _[___, up, ___] ^= "UpValueEva …
answered Jul 21 '12 by Szabolcs
7
votes
Like in all other systems I am familiar with, variable and function definitions exist in memory (RAM) only and do not persist across sessions. If you want a definition to persist, you must save it ex …
answered Mar 15 by Szabolcs
39
votes
I'll cover a few typical uses of Block, neither of which is possible using Module or With. Temporarily removing definitions When you do Block[ {a = x}, ... ] the original definition of a is effe …
answered Jan 23 '12 by Szabolcs
14
votes
If you just want backwards compatibility, there is no need to create any symbols in the System context. It seems like a bad idea to do such things. A package should create symbols only within its ow …
answered Jul 6 '18 by Szabolcs
38
votes
In the days when computers were slower, and the kernel took a long time to start up (in wall time), a little package was made to help with cleaning up without having to restart the kernel. This packa …
answered Jan 28 '12 by Szabolcs
4
votes
In this case you need to use :> instead of ->: {1, 2, 3.0} /. a_Integer :> a + 1 This will ensure effective localization. Refereces: Rule and RuleDelayed Immediate and Delayed Definitions What …
answered May 28 '14 by Szabolcs