Tagged Questions
4
votes
3answers
95 views
Modify this code using Module and While
I have written a recursive function and would like to re-write the code using Module AND While to compare the timings.
Here is my recursive function for f[n], where 6 n f[n] = f[n-1] + n! for n>0 and ...
13
votes
1answer
182 views
Is the sharing of variables in Module/Block within Compile documented behavior?
Today I noticed something, I think for the first time.
When used inside Compile variable values within Module (and ...
6
votes
4answers
188 views
How to set Block local variables by code?
I need to create a user defined Block function where the Block variables values are defined by code. For example, imagine I have:
...
10
votes
1answer
154 views
Modules that initialize themselves on first call
I use a lot of functions that extract a specific data item from a file with many data items. I want these functions to load data (slow) and return the item (fast) on first call, but just return the ...
4
votes
1answer
119 views
How to avoid conflicts between local variable names and symbolic arguments in Block constructs?
I am using Block inside the definition of some recursive functions.
If the Block definitions use short variable names, like ...
4
votes
4answers
202 views
why I see the error “only assignments to symbols are allowed” in Module context and not in global?
V 8.04, on windows.
When I type
Remove["Global`*"]
foo[] := Module[{Subscript[a, 1] = "x"}, 0];
foo[]
I get the expected error "only assignments to symbols ...
5
votes
6answers
492 views
How can you give a Module a context and have its local variables and Modules belong to that context?
What would be the best way to give a module its own context and have its local variables and Modules belong to that context?

