Tag Info

Hot answers tagged

41

LongestCommonSequencePositions and LongestCommonSubsequencePositions Their use is analogous to LongestCommon(Sub)sequence but they return the position of the first match instead. ClipboardNotebook[] can be used to access the clipboard. NotebookGet@ClipboardNotebook[] will give a Notebook expression with the current contents of the clipboard. I use this ...


25

Thinking about a recent answer made me wonder exactly which functions in Mathematica use Assumptions. You can find the list of System` functions that use that Option by running Reap[Do[Quiet[If[Options[Symbol[i], Assumptions]=!={}, Sow[i], Options::optnf]], {i, DeleteCases[Names["System`*"], _?(StringMatchQ[#, "$"~~__] &)]}]][[2, 1]] which (can be ...


21

One undocumented function I find useful is Precedence For example: {#, Precedence@#} & /@ {Plus, Minus, Times, Power, Apply, Map, Factor, Prefix, Postfix, Infix} // TableForm giving: Plus 310. Minus 480. Times 400. Power 590. Apply 620. Map 620. Factor 670. Prefix 640. Postfix 70. Infix 630. Precedence is described in a ...


17

This method only returns a few of them, hopefully including some undocumented ones. It's not intended to be a complete answer. fnames = FileNames[ "*.nb" | "*.tr", {FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "StyleSheets"}], FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources"}], ...


16

You may use Tally to finish the task as follows: Cases[Tally[list], {x_, 4} :> x] the result will be {a,b}.


16

I got a request to post here the undocumented tokens I already posted in an old answer on SO. For completion, I merged my list (which is also in the link provided by @Chris) with @Rojo's list. Later, the list was merged with Vladimir's list below and two more tokens were included, so as to have here a repository of all known FE tokens. Please feel free to ...


11

The following simulates Mathematica's behaviour after using it for more than 24 hrs. MathLink`CallFrontEnd[FrontEnd`UndocumentedCrashFrontEndPacket[]] Works as advertised! :D


11

I quite like SequenceLimit[] myself; it is a function that numerically estimates the limit of a sequence by applying the Shanks transformation (as embodied in Wynn's $\varepsilon$ algorithm). The method is a particularly nice generalization of the probably more well-known Aitken $\delta^2$ transformation for accelerating the convergence of a sequence. ...


11

There is a list posted in 2009 from John Fultz on the MathGroup here. No version information. Rojo's list has some new ones. Length@RojosList 56 Length@JohnsList 266 Length@Intersection[RojosList, JohnsList] 35


10

No so much a function as an option... Problem: You embedd a CDF on a web page but the content is rendered as grey boxes. Cause: This is a security issue, the same as when you open a notebook with dynamic content from an untrusted path on your computer. Solution: On your desktop you are asked if you want to enable dynamic content. You press the button and ...


10

Another interesting approach: i = 0; Map[0 # + (20 + 0.1 i++) &, A] {{20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20.}, {20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1}, {20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, ...


9

Here is a combined list from belisarius' old answer of undocumented tokens given by John Fultz in Jan 2009, and tokens obtained from Mathematica system files. 80 of these were not listed in earlier answers. The list is obtained using Rojo's idea, but upgraded and corrected. fnames = FileNames["*.nb" | "*.tr", { FileNameJoin[{$InstallationDirectory, ...


8

I'm not going into the well-coded part of your question (as this is rather subjective), but a package that I've (cursorily) examined and which looks nice is this quantum notation package, which has lots of custom notation and corresponding palettes.


8

The code given by Rojo and sunt05 is almost surely the cleanest: Cases[Tally @ list, {x_, 4} :> x] However, here are some other possibilities: Cases[Split @ Sort @ list, {x_, _, _, _} :> x] Cases[Split @ Sort @ list, {Repeated[x_, {4}]} :> x] Cases[Last @ Reap[Sow[1, list], _, {#, Tr@#2} &], {x_, 4} :> x] Module[{c}, c[_] = 0; ...


7

Something like v /. Dispatch[Thread[both[[All, 1]] -> both]] should operate much faster, especially on large lists. Surround with something like cases, e.g., Cases[v /. Dispatch[Thread[both[[All, 1]] -> both]], {{__}, _}] For only "changed" to be in list. Many, many ways to do this, btw... e.g., if the output desired is always in order of both ...


6

Is this what you are looking for? data = {b (a/bc t)^r, a/b (b t)^r, a (c/d t)^r}; sums = data /. Power[x_, r] -> x/(1 - x) $\left\{\frac{a b t}{\text{bc} \left(1-\frac{a t}{\text{bc}}\right)},\frac{a t}{1-b t},\frac{a c t}{d \left(1-\frac{c t}{d}\right)}\right\}$


6

maybe the fastest, if the data is smooth, just take every Nth point.. ListPlot[Transpose[{x, y}][[;; ;; n/1000]], Joined -> True] Another sometimes useful approach especially if you have unordered data: ListPlot[RandomSample[Transpose[{x, y}], 1000]]


6

Here's another way. It's not as fast as george2079's but since speed is an issue in the question, perhaps it is worth comparing them all. It uses the ListLinePlot options MaxPlotPoints and PerformanceGoal. One feels, perhaps, that lurking in the undocumented Method option there ought to be a setting that approaches the performance of george2079's ...


5

Besides the quantum package already mentioned by @Sjoerd, the package with the most customized notation that I know of is the THEOREMA package. You can freely use the package and admire the complex logicographics notation created, but the code is not available for inspection. Finally, the OP leaves me No-Escape (pun intended) but to mention my WildCats ...


5

TetGen Mathematica has a nice library TetGenLink to produce irregular 3D meshes. Original TetGen has a lot of features and not all of them available by TetGenLink. One of the features is the setting up the vertex metrics to produce non-uniform grids Fortunately, the corresponding function is implemented but not documented ...


5

MapThread[Thread[List[RandomChoice[#1, #2], #3]] &, {community, cant, Range@Length@cant}] (* {{{2, 1}, {1, 1}, {3, 1}, {4, 1}, {6, 1}}, {{3, 2}}, {{4, 3}, {1, 3}}, {{2, 4}, {3, 4}, {1, 4}}, {{2, 5}, {3, 5}, {1, 5}, {6, 5}}} *) Some variations: MapIndexed[Thread[List[#1, First@#2]] &, MapThread[RandomChoice[#1, #2] &, {community, cant}]] ...


5

ClearAll[miF, rPF, tBF]; miF = MapIndexed[20 + .1 (#2[[1]] - 1) &, #, {2}] &; or rPF = ReplacePart[#, {i_, _} :> (19.9 + 0.1 i)] &; or tbF = Block[{j = 0}, Table[ 0 i + 20 + 0.1 j++, {i, #}]] &; Example: A = {{0.620161, 0.320312, 0.94842, 1.11844, 1.12045, 1.12539, 1.13177, 1.13142, 1.15048, 1.23244, 0.721388, 0.708943, ...


5

Using: A = {{0.620161, 0.320312, 0.94842, 1.11844, 1.12045, 1.12539, 1.13177, 1.13142, 1.15048, 1.23244, 0.721388, 0.708943, 0.750067, 0.744916, 0.720972, 0.674833, 1.29773, 1.29514}, {0.620161, 0.320312, 0.94842, 1.11844, 1.12045, 1.12539, 1.13177, 1.13142, 1.15048, 0.721388, 0.750067, 0.744916, 0.720972, 0.674833, 1.29383, ...


4

There are built-in functions to do that. Mean/@Partition[lst,365*8] Variance/@Partition[lst,365*8]


4

You can use Interpolation: n = 16000000; x = 0.5 Range[-(n/2), n/2]; y = 2.5 Range[-(n/2), n/2]; interpolated = Interpolation@Transpose[{x, y}]; Plot[interpolated[x], {x, -0.5 n/2, 0.5 n/2}] Interpolation makes it much faster to plot the graph since Plot doesn't have to plot all points in order to generate a good looking graph. Generating the plot in ...


4

Table[A[[i, All]] = Table[20. + n/10, {n, 0, Length[A] - 1}][[i]], {i, 1, Length[A]}]; A // TableForm


3

DeleteDuplicates[Select[list, Count[list, #] == 4 &]]


3

This is an easy application of Gather and replacement rules. Assuming your two lists are: list1 = {{a, b, c, {d, e, f}, g, h}, {l, m, n, {o, p, q}, r, s}, {u, v, w, {x, y, z}, a, b}}; list2 = {{a, b, c, {d, e, f}, i, j}, {u, v, w, {x, y, z}, d, e}}; then you can join them as desired with Gather[list1 ~Join~ list2, #1[[;; 4]] == #2[[;; 4]] &] /. ...


3

I suggest those two tutorials for writing Mathematica packages, unfortunately the first one is in Spanish, yet I do believe it will be useful for anyone because the step-by-step images; the second one is in English.


3

Posting this because I was a but surprised by the result.. n = 10^6 Last@Last@Reap[Do[ Sow[2 i + j - 2], {i, n}, {j, 2}]] == Range[2 n] // Timing -> {3.307221, True} Table[Unevaluated@Sequence[2 i + 1 - 2, 2 i + 2 - 2], {i, n}] == Range[2 n] // Timing -> {1.918812, True} Flatten@Table[ 2 i + j - 2, {i, n}, {j, 2}] == Range[2 n] // Timing -> ...



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