New answers tagged

3

This is one aspect of a classic problem: Plot is HoldAll. So, moreProp is not being evaluated. I think the most effective way to work around this is to use With (cf. this question) to inject the values into Plot, e.g. newPlot[func_, range_, prop___] := With[{mp = moreProp}, Plot[func, range, prop, mp]] Then, it works: Alternatively, you can use ...


3

A workaround is to use lexical (Module) scoping to localize B for Do in addition to the dynamic scoping that Do already has. Module[{B}, Do[f @@ B, {B, {{X, Y}}}]]; In short, Do does scoping by temporarily changing the value of B. This B is however still the very same symbol both inside and outside of Do, it just has a different value inside of Do. ...


2

First, I recommend reading Leonid's amazing answer about scoping constructs. It explains very clearly what the difference between lexical and dynamic scoping is. The docs say the following about Do: Do effectively uses Block to localize values or variables. That means Do uses dynamic scoping. That is, during the execution of the Do iteration, B has ...



Top 50 recent answers are included