0
votes
2answers
99 views

Are there ways to create local variables analogous to a local variable in C++ and other languages? [closed]

There has been a great deal of discussion on local variables in Modules and Manipulate. If I am reading this correctly, local variables in a language such as C++ or C# are not exactly analogous to ...
5
votes
3answers
143 views

Prevent iterator name from being confused with symbol passed into function body

I have a massive amount of code with lots of Table and Sum inside a Module. Each with their ...
1
vote
0answers
42 views

Settings to disable global scope

I am building a fairly large application in Mathematica, and globally scoped variables are causing issues. I would like globally scoped variables to be out-of-scope for my expressions, except by ...
0
votes
0answers
90 views

Programming a Meijer G related result

I am not that new in Mathematica, but I do not remember I have ever used it for programming (like we may do in Java). I have an important result given here by this integral: $$ \int_0^{+\infty} ...
2
votes
1answer
249 views

Call Functions From File Without Modifying Context (Sandbox)

Let's say I have file named test.m containing test[arg1_] := ( Print[arg1];) What is the best technique for calling test like ...
8
votes
1answer
135 views

Is it possible to write a function immune to symbol redefinitions in any Block surrounding its invocation?

Normally, semantics of symbols used in a function definition can be changed by their redefinitions in Blocks surrounding the function invocation: ...
8
votes
1answer
120 views

Is it possible to use the global definition of a symbol as part of its new local definition set in a Block?

Consider the following expression: Block[{Print = CopyToClipboard}, doSomething[]] Now all calls to Print from ...
2
votes
1answer
124 views

Odd edge-case behavior of Block

In this example, Block is used to localize the variable cache as used in the function g when called from the function ...
4
votes
3answers
161 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 ...
14
votes
1answer
302 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 ...
7
votes
4answers
387 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: ...
12
votes
1answer
278 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
180 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 ...
6
votes
6answers
584 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?