37 questions linked to/from How to avoid nested With[]?
110 views

Local variables in sums and tables - best practices?

Stumbled on Local variables when defining function in Mathematica in math.SE and decided to ask it here. Apologies if it is a duplicate - the only really relevant question with a detailed answer I ...
233 views

Replace nested external definitions in Compile

f = #^2 &; Compile[{{x, _Real, 1}}, f /@ x, CompilationOptions -> {"InlineExternalDefinitions" -> True}] // CompilePrint works fine. ...
164 views

Where can I put my conditions?

I just learned in this answer that you can put conditions inside a With and thus use computed values in them, like this: ...
721 views

Functional programming Style & Performance

Hello i have been spending time to convert my R tools into Mathematica Packages mainly because i like the functional programming style in Mathematica. In doing so it seems that i run into one ...
357 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: ...
501 views

Permuting indices to form fully symmetric tensor with repeated indices

I have written a function (version 8) that takes as an input a list of indices such as {i,j,k} and outputs a fully symmetric tensor function containing $p_i$ and \$...
65 views

LetL Breaks in ParallelEvaluate

This was a wild head-scratcher for me to hunt down, but I now am sure LetL is the culprit. Here's a small example: ...
101 views

Block assignments not quite sequential?

With scalars, Block acts like Scheme's let*, that is, the assignments (appear to) happen sequentially: ...
277 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: ...
67 views

Weird behaviour of If inside of Block definitions?

I am on Mathematica 9 and I have discovered, that, when I use If inside of the definitions of the Block variables, then other, ...
58 views

Variables referring to other variables within Module

The following doesn't work: Lol[x_, y_] = Module[ {w=x+1, z = w + 1}, z] because z refers to ...
319 views

Best approach for 'manual' common subexpression elimination

I have working code, but am looking for ways to make it more elegant. I have a fairly large expression with plenty of repetition and structure. A shortened toy example is ...
48 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?