# Tag Info

2

Better late the never, right? I created this answer while thinking about one of recent questions that was a duplicate of this one. I kind of like this way, it is compact and without #&@ :) ClearAll[VNL]; SetAttributes[VNL, HoldFirst]; VNL[list_] := Thread[ Hold[list] /. OwnValues[list] ] /. Hold[s_] ...

1

You wrote: Now, it's not hard to change one of these functions: assoc["PHASES", "GAS"] := assoc["PHASES", "LIQUID"][#] * 0.7 * # & ...and this works perfectly fine. But in practice, I might be changing these functions or other values many times and a programmatic way would be preferred. Perhaps a meta-programming approach would be ...

0

This only addresses your toy example, but what about this approach that avoids ReplacePart: assoc = <|"PARAMETERS" -> <|"A" -> 1, "B" -> 2|>|> // Dataset phases["LIQUID"][x_] := assoc["PARAMETERS", "B"]* x phases["GAS"][x_] := phases["LIQUID"][x]*0.5 *x Plot[phases["GAS"][x], {x, -5, 5}] Or even as operators: ...

4

ReplacePart did not work with associations in versions 10.0.0 and 10.0.1, but it does as of version 10.0.2. The proposed expression shown in the question will work in 10.0.2 (after making the minor adjustment of putting parentheses around the replacement function): newassoc = ReplacePart[assoc , { {"PHASES", "GAS"} :> (assoc["PHASES", "LIQUID"][#] ...

1

If you use SetDelayed then you loop will call Abort. With Set (=) res2 has not value at all. You can check it evaluating: a =. ; a = Abort[] (*new cell*) a a So: res = 0; res2 = ""; CreateDialog[{TextCell["Do you want to continue calculations?"], Button["Proceed", DialogReturn[res2 = True]], Button["Cancel", ...

3

The difference is the following: When you call Quit[] as input in a notebook, then the front end sends this command over the main MathLink connection to the Kernel like any other input. If you are already evaluating a long-running (or hanging) command, the Kernel won't quit because (as Alexey already pointed out) the quit command is queued and waits until ...

4

Normally in Mathematica, you just need to type the integral and it will evaluate without needing to specify a substitution or anything. Unfortunately Mathematica does not know how to do this integral. I agree with what george2079 said in the comments: This is an example where it is far easier to do the substitution by hand and feed the integral in terms ...

4

expr = (((w + a) Exp[r t]) + (s Exp[d t] + o*l) p Exp[(r - d - (1/2)*q^2) t + (x Sqrt[t]*q)])^(1 - c) /. {d -> 0.0269, q -> 0.3315, r -> 0.0435, t -> 1, w -> 1.1465, p -> 100, l -> 1, c -> 3, a -> 0.0941, s -> 0.0029, o -> 0.0089}; NExpectation[expr, x \[Distributed] NormalDistribution[0, 1]] (* ...

0

Learn all you want at http://mathworld.wolfram.com/GammaFunction.html or several other sources on the internet. The Gamma Functions is one of several standard integrals.

1

That's because you set Psi to accept only real x. Meanwhile symbol x is not generally considered to be real by Mathematica, so just delete _Reals or use it with assumptions: Assuming[x \[Element] Reals , \[Psi][x, 1]]

1

The following is a slightly simplified version of your DynamicModule: DynamicModule[{x}, Column[{Button["start", x = 0; RunScheduledTask[x++;, {1, 5}]], Row[{Dynamic[HoldForm[x]], " = ", Dynamic[x]}]}] ] When you evaluate this for the first time, underneath the button you see the output (* FEx$$82 = FEx$$82 *) (very likely with a different ...

8

You cannot Quit kernel while evaluation is still running: the Quit[] command will be placed in the queue and executed only after finishing of evaluation of all the previous inputs. In contrast, Evaluation>>Quit Kernel will quit the kernel immediately even if it is still running. UPDATE As Kuba notice in the comments, via "Preemptive" link it is ...

4

I agree with @Ymareth that the simplest thing would be to have the calling notebook take explicit measures to communicate the context to the target notebook. However, if for some reason it is undesirable to alter the calling notebook, then here is another way. When one notebook open in the front-end invokes another notebook, InputNotebook[] will normally ...

7

Why not just set a symbol to have a value within the calling notebook? Something like... $callingNotebook = EvaluationNotebook[]; Then in the called notebook see if$callingNotebook has a value.

1

This is a comment turned into an answer as per request. Also note that I changed == into ===, which seems to be crucial. In case you think an abort may happen at an unpredicted moment, you can set $Post = Function[If[# ===$Aborted, Null, #]];

Top 50 recent answers are included