Linked Questions

2
votes
2answers
289 views

Local variables whose definitions depend on each other [duplicate]

Consider the following (pseudo-)function definition: f[l_] := Let[{ a = Length[l], b = First[l], c = b/a, }, c*10] So for ...
3
votes
1answer
284 views

Is there any way to implement a “sequential” With[] in Mathematica? [duplicate]

I want the equivalent of Scheme's let*, or basically, a sequential With that works like this: ...
2
votes
1answer
231 views

Reuse local variable in declaration within With [duplicate]

Considering the richness of Mathematica.SE, I am quite surprised I could not find my answer... I am very sorry if it is a duplicate. Consider the following example: ...
1
vote
0answers
76 views

What's the best practice for nested local constants? [duplicate]

Possible Duplicate: How to avoid nested With[]? I have many situations where I have a constant that is local to a function, with other constants that are computed from it. I see that I can ...
1
vote
0answers
44 views

Dependent variables in With operator [duplicate]

I want write something like this With[{x=1, y=x+1}, y] and get 2 as an answer. What is the correct way to do this?
528
votes
19answers
132k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
73
votes
3answers
8k views

Metaprogramming in Mathematica

Being functional, and having no "quotation", i.e. essentially treating data and programs semantically same, Mathematica seems naturally capable of doing metaprogramming. But could anyone construct a ...
44
votes
5answers
3k views

How to create symbols from strings and set values for them?

I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to ...
115
votes
1answer
7k views

File-backed lists/variables for handling large data

Background Currently I am working with some large data (most of it generated by Mathematica itself). I usually find it a hassle to do this. For example, I just exported a large amount of data to ...
22
votes
4answers
2k views

How to match a pattern with a pattern?

UPDATED This question is about: "What is the pattern to match a pattern-definition, exactly as it is written?" My original question is now split according to Mr.Wizards insightful answer below. This ...
19
votes
3answers
857 views

Generating assignments and transforming code inside held forms when generating code

I have been playing with slightly above trivial code manipulations in Mathematica. I thought Mathematica would be great for this kind of work because of rule replacement and expression manipulation, ...
21
votes
2answers
554 views

Should I always be using Module in functions unless I explicitly want global variables?

I define functions a ton. In the past, I've mostly just defined my functions like: myFunc[var1_]:=( var2=var1^2; Return@var2; ) And I haven't run into too ...
18
votes
2answers
458 views

Clean and handy Options management/filtering

the case I want to be able to create a function with some default options but also without need to add full explicit list of options available for it. And then inside I want to be able to filter ...
21
votes
1answer
422 views

Bug with iterated With: Referring to function arguments invalidates previous definitions

Thank you for your report. I have forwarded your report to the appropriate team for review. - WRI ...
18
votes
1answer
555 views

Removing calls to MainEvalute when using inlined compiled closures

This question is tightly related to the answer Shaving the last 50 ms off NMinimize. There @OleksandR shows how inlined closures can be used to eliminate calls to ...

15 30 50 per page