Tag Info

Hot answers tagged

13

Perhaps the simplest way is to use the built in function Information, which is the programmatic form of ?? Information[#, LongForm -> False] & /@ functionslist gives a long list of (short) function definitions. By the way... it's easy to figure this kind of thing out -- in this case, I highlighted the symbol ?? (double question mark) and pressed ...


10

I use something similar to @Sjoerd's suggestion with OpenerView. Here is the essence: ClearAll[Inspect] Inspect[x_] := inspect2[x] ClearAll[inspect2] SetAttributes[inspect2, HoldAll] inspect2[x:_[a__]] := OpenerView @ {inspectView[x] // Framed, Dynamic @ Column[List @@ inspect2 /@ Hold[a]]} inspect2[x_] := inspectView[x] SetAttributes[inspectView, ...


9

Try OpenerView[{Head[#], args @@ #} ] & //@ g [For this demonstration I opened a few of the OpenerView-s. There are many more to explore.]


5

Similar approach to Mr Wizard's but using a silly trick with pure functions rather than the auxiliary function f: Replace[{{1, 2, 3}, {-∞, 1, 2}, {1, 2, ∞}, {-∞, 1, 2, ∞}, {-∞, ∞}, {∞}, {-∞}, {}}, {a : (-∞ | PatternSequence[]), Shortest[x___], b : (∞ | PatternSequence[])} :> {#2 &[a, Unevaluated[], -∞], x, #2 &[b, Unevaluated[], ∞]}, {1}] ...


5

Let me relax rules a bit just to write some compact code without external functions. I can add -∞ and ∞ and delete double infinities Replace[{{1, 2, 3}, {-∞, 1, 2}, {1, 2, ∞}, {-∞, 1, 2, ∞}, {-∞, ∞}, {∞}, {-∞}, {}}, {mid___} :> ({-∞, mid, ∞} /. {x_, x_, y___} :> {y} /. {y___, x_, x_} :> {y}), {1}] (* {{-∞, 1, 2, 3, ∞}, {1, 2, ∞}, {-∞, 1, 2}, {1, ...


5

I set out to condense the rules shown in the question by use of "vanishing patterns" but I found it rather difficult. The best I could come up with is this: f[x_ | __] := x Replace[ {{1, 2, 3}, {-∞, 1, 2}, {1, 2, ∞}, {-∞, 1, 2, ∞}, {-∞, ∞}, {∞}, {-∞}, {}}, {a : -∞ ..., Shortest[s___], b : ∞ ...} :> {f[a, -∞], s, f[b, ∞]}, {1} ] {{-∞, 1, 2, 3, ∞}, ...


5

It is hard to figure out what you really need. If you describe the surrounding application you may get better answers. You should avoid using capital letters to start user Symbols in Mathematica as this may conflict with internals. If I follow your updated question I believe you want this: fn[x_, y_] := Min @ Quotient[{x, y}, {2, 1}] Test: fn[2, 1] ...


5

You can also use the usage messages: usageInfo = With[{func = Symbol[#]}, func::usage] &; cF = Column[Style[#, 16, "Usage", Background -> None] & /@ #, Dividers -> All, Background -> {{LightBlue, LightOrange}}] &; usageInfo /@ functionslist[;;8]] // cF Alternatively, make the usage message content a Hyperlink to the ...


5

This may help to indicate what goes wrong. steffensenMethodB[ func_, {a_?NumericQ, b_?NumericQ}, ε_?NumericQ] := Module[{φ, ini = First@biSection[func, {a, b}, .5*10^-3], f, g}, φ[x_] := x + func[x]; f[x_] := -(φ[x] - x)^2; g[x_] := (φ[φ[x]] - 2 φ[x] + x); NestWhileList[(Print[{#, f[#], g[#]}]; # + f[#]/g[#]) &, ini, Abs[#1 - #2] > ε ...


4

I don't know anything about the structure of an InterpolatingFunction (the documentation doesn't seem to provide much information about it), but could you just reconstruct your function like this: data = {{0.5`, 0.01739227213704432`}, {0.75`,0.01526028474172406`}, {1.`, 0.01376257284655001`}, {1.25`,0.01269413117458243`}, {1.5`, 0.01187709007513161`}, ...


4

belisarius left a hint in a comment on how to solve this problem more efficiently, but I'm going to take it at face value and try to optimize your code. The pattern matcher is slow, so you don't want to use the pattern matcher in any kind of loop generally. On my computer your code takes 3.87 seconds to execute, whereas ParallelSum[ n ...


3

If the curly braces are left out, this seems to work. Remove[eMap]; eMap = Dataset[{<|"ModuleId" -> 0, "SegmentId" -> 0, "x1" -> 0, "y1" -> 0, "z1" -> 0, "x2" -> 0, "y2" -> 0, "z2" -> 0|>}]; eMap = AppendTo[ eMap, <|"ModuleId" -> 0, "SegmentId" -> 1, "x1" -> 1, "y1" -> 0, "z1" -> 0, "x2" -> ...


3

expr = {{1, 2, 3}, {-∞, 1, 2}, {1, 2, ∞}, {-∞, 1, 2, ∞}, {-∞, ∞}, {∞}, {-∞}, {}}; Not general but useful: Flatten[Replace[Split[{-∞, ##, ∞}], {x_, x_} :> Sequence[], {1}]] & @@@ expr Not working if in the list are repeated elements already. Also Flatten should be restricted if we are dealing with more complex structures.


2

Just an example: tab = Table[{If[PrimeQ[i], "type" -> "Prime", "type" -> "NoPrime"], "n" -> i, "dc" -> DigitCount[i!, 2, 1], "dc1" -> DigitCount[i! + 1, 2, 1]}, {i, 20, 40}]; make a Dataset: ds = Dataset[Association @@@ tab] get the column heads: First@Keys@ds You can then make a table, export, to Excel, or whatever. Excel Export of ...


2

This is one solution, encapsulating all your expressions in the form: AbsoluteTiming[expr1;expr2;]. AbsoluteTiming[ a = Range[123456]; Pause[1]; Total[a] ] (* 1.01503 seconds, returns 7620753696 *) Needs["GeneralUtilities`"] AccurateTiming[ a = Range[123456]; Pause[1]; Total[a] ] (* 1.001246 seconds *) Also works fine with Timing[] for just ...


2

Here is my try using MapIndexed, Mouseover, and Tooltip. The idea is to highlight parts of an expression as the mouse is over it and to display at the same time the exact level indices corresponding to it. Here is a simple example to understand the core idea : myExpr = {{1, 2, {11, 22}}, {3, 4, {111, {222}}}}; and level = 3; (* For example all parts at ...


2

There's no built-in automated way to interrupt a calculation, quit Mathematica, then resume the calculation at a later time. It is however often possible to implement something like this yourself. I have done this several times when the problem was simple enough to allow it. But it needs to be done manually. You need to store the state of the calculation ...


1

My feeling is that this question is probably too broad and a definitive answer might be too long or nearly impossible. This a comment to point out issues to consider in deciding whether and how to localize symbols. + Is the application self-contained? Or does it consist of several components that need access to a shared variable (e.g. a database or ...


1

The most clean formulation, I believe, is “add an element and delete a pair if one occures”. Thus, I would just use something similar to idempotentAppend[{most___, x_}, x_] := {most}; idempotentAppend[l_List, x_] := Append[l, x]; idempotentPrepend[{x_, most___}, x_] := {most}; idempotentPrepend[l_List, x_] := Prepend[l, x] with “idempotent” in the ...


1

Your notebook may have the option OutputAutoOverwrite set to False, or the output cell below your input has the setting CellAutoOverwrite->False. You can use the Option Inspector in the Format menu to set this option.



Only top voted, non community-wiki answers of a minimum length are eligible