New answers tagged

2

You might find use in this definition of $Post: $Post = Function[, Unevaluated[#] /. $Failed :> RuleCondition@FrontEndTokenExecute["EvaluatorAbort"], HoldAllComplete]; With this defined any printed output that contains $Failed should trigger an abort of all subsequent cells. Reference: Pure function with attributes of arbitrary number of ...


0

Here is an alternate solution based on the Trace function: Trace[f[3]][[2]] Sin[\[Pi] 3]+Cos[\[Pi] 3] Or better maybe: Trace[f[3], _[_] +_[_]] {Sin[\[Pi] 3]+Cos[\[Pi] 3]}


1

If you have a whitelist of symbols, here's a flexible way to do it with Inactivate and some code-injection trickery: $inactiveSyms = Hold[{Sin, Cos, Tan}];(* in case you want to localize a symbol with OwnValues *) withInactiveSymbols~SetAttributes~HoldAll withInactiveSymbols[expr_, symList : Hold[{___Symbol}] | Automatic : Automatic] := Replace[ ...


0

Here is my initial solution: Block[{Sin = HoldForm[Sin], Cos = HoldForm[Cos]}, f[3]] Cos[3 \[Pi]]+Sin[3 \[Pi]] The idea is to use the Block function to evaluate f[3] in an environment where the Sin and Cos symbols are temporarily rebound to their "unevaluable" equivalent1 1I'm not sure this is the correct wording. Please correct me if necessary!


2

Your file "database_IOtables _SA _NO _UK _ 2000_ 2015_run _ 1.m" isn't a Notebook, but a Package - right? Hence the EvaluationElements option is simply ignored, because Packages has no Cells and associated CellTags. Obviously, you are trying to adapt the code from the section Examples ► Applications on the Documentation page for NotebookEvaluate. Here is ...


0

For simulation purposes, one can use the following code with a button to generate different sets of parameters at the same time rather than changing individual parameters. The example uses "Initialization" to change parameters (k1,k2,k3,k11,k22) at the same time. Press Button to generate new parameter values for (k1,k2,k3,k11,k22) based on Initialization. ...


0

Come to think about it, it is simple enough to pass arguments Unevaluated to Through, so perhaps everything works correctly.


7

AFAIK, there is no way to get what you want with the built-in Reap and Sow. However, here is a drop-in Reap - Sow replacement based on Internal`Bag structure, which is also the one that the actual Reap and Sow are based on: SetAttributes[withSideEffect, HoldRest]; withSideEffect[code_, sideEffectCode_] := (sideEffectCode; code); $storage = <||> ...


3

Not sure why you want to use ParametricPlot in the Manipulate, while you had used Plot in your first visualization. Consider that you have three components in your solution, so that would not make sense for a 2D parametric plot; you would have to use ParametricPlot3D instead. I suspect that neither are what you want, and instead you simply want plots of the ...


5

One part of the problem has already been mentioned by @C.E. in his answer: Since Association is seen as atomic by the pattern matcher, no insertion of matched expressions happens within it. The reason this is a problem at all is that your postproc is not actually evaluated after the matches have been identified, but before. To prevent evaluation of the ...


3

A possible workaround: keys = ToString /@ syms; postproc[x_, h_: keys] := Thread[h -> x] Association @@@ Cases[exprs, # -> postproc[syms], Infinity] & /@ patts {{<|"x1" -> 14, "x2" -> x2, "y" -> y|>}, {<|"x1" -> x1, "x2" -> 12, "y" -> 3|>, <|"x1" -> x1, "x2" -> 2, "y" -> 8|>}}


7

NotebookEvaluate is implemented using a dialog subsession. The implementation literally evaluates Dialog[] and then begins initiating the evaluation of the notebook. The reason for doing this is so that we can achieve the behavior of each cell of the target notebook going through the full main loop evaluation, without disrupting a main loop evaluation that ...


Top 50 recent answers are included