Tag Info

New answers tagged

1

Evaluate specifically operates to force evaluation: Evaluate[expr] causes expr to be evaluated even if it appears as the argument of a function whose attributes specify that it should be held unevaluated. You can use Evaluate to override HoldFirst, etc. attributes of built-in functions. Evaluate only overrides HoldFirst, etc. attributes ...


-1

You can localize x using...Module[{x}, Plot[Evaluate[Table[Z[x,y]...


12

Based on Mr.Wizard's answer and Szabolc's comments to it, I now understand that the code I posted does have undesirable side-effects and it should be avoided. Specifically, the scoping constructs Module and Block are meant to completely localize the variables in their first argument (for more information see this question). However, placing their scoped ...


6

I believe that highlighting is there specifically to encourage you to use DynamicModule rather than Module: DynamicModule[{A = 1}, Manipulate[Plot[A Sin[k x], {x, 0, 20}], {k, 1, 10}]] One reference: http://forums.wolfram.com/mathgroup/archive/2011/Sep/msg00198.html Also related: Table function with Part[] call misbehaving, but only after initial ...


2

I was somewhat perplexed by your use of Module here, and I don't think you every explicitly stated the reason you are using it, but I am going to assume that you want to prevent e.g. f[-6] from having a global value after your operation is performed. For that you want Block instead of Module. You will also need to Evaluate lengthRow or you will reassign ...


1

I'd go for Count: Count[row, 2] 3 And in case you want to count all elements of your row, you can also use Tally: Tally[row] {{-1, 5}, {1, 5}, {2, 3}, {3, 1}, {-2, 2}, {-3, 2}, {-4, 1}, {-5, 1}} EDIT Given the OP's updated goal, this should suffice: row /. Rule @@@ Tally[row] {5, 5, 3, 1, 5, 5, 3, 5, 5, 5, 2, 2, 5, 5, 2, 2, 1, 1, 5, 3} ...


8

In V10 -- Needs["GeneralUtilities`"]; ?GeneralUtilities`Where Where[ass1, ass2, ..., expr] is a version of With that supports multiple sequential assignments. Needs["GeneralUtilities`"]; Where[v1 = #, v2 = f[v1], g[v1, v2]] (* g[#1, f[#1]] *) Where[x = 2, t = x^2, Hold[x + t]] (* Hold[2 + 4] *)


1

One potential solution to this would be using PreemptProtect to prevent interruption. For the example from the main question, PreemptProtect@Block[{x}, Pause[5]]


2

This could be a way of achieving what you want (if I understood you correctly): ClearAll[SolveEquation]; SolveEquation[x_Symbol, xp0_, x0_] := Block[{x, y, z}, Module[{sol}, sol = First@ Flatten[NDSolveValue[{x''[t] + x'[t]^3 == x[t]^2, x'[0] == xp0, x[0] == x0}, {x}, {t, 0, 100}]]; { x -> sol, y -> (x[#]^(1/2) ...



Top 50 recent answers are included