Tag Info

Hot answers tagged

39

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 ...


23

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 ...


20

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 ...


16

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}.


15

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 ...


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

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

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. ...


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 ...


7

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


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\}$


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

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

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 ...


4

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


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 -> ...


3

Usually, there are efficiency advantages to generating all of your random numbers in one go, but in this instance, it makes little difference if you generate all in one go, or in tuples of 5 (million of times). I am not sure what you are doing with them, but usually one is doing something like computing a sample mean, or adding them up or similar: ALL IN ...


3

I propose two different solutions with comparable speed. Some input set n = 20; SeedRandom[0]; L = Sort[RandomSample[Subsets[Range[n], {2}], RandomInteger[{1, Binomial[n, 2]}]]]; Length[L] 168 The main idea: let's recursively look for all possible non-duplicated subsets and count them. It is relatively fast and it does not require a lot of ...


2

Thread[{RandomSample[community[[#]], cant[[#]]], #}] & /@ Range[Length[community]] (* {{{2, 1}, {3, 1}, {5, 1}, {1, 1}, {4, 1}}, {{3, 2}}, {{2, 3}, {4, 3}}, {{3, 4}, {2, 4}, {1, 4}}, {{3, 5}, {5, 5}, {4, 5}, {1, 5}}} *)


2

{(community[[#]]~RandomSample~1)[[1]], #} & /@ ConstantArray[#, cant[[#]]] & /@ Range[Length@cant]


2

Here is a fairly general solution for the infinite sum of a real geometric term in an arbitrary variable var from var = n0 to Infinity. There may be some expressions involving special functions that can be simplified to a geometric term that Simplify might miss, and the use of PowerExpand may be omitted if Complex bases are to be used. It was included here ...


2

fun = {(x - 0.5)*5*^-8, (y - 0.5)*5*^-8, 0.1*Exp[-(x*5*^-8 - 1.28*^-5)^2/1*^-12]*Exp[-(y*5*^-8 - 1.28*^-5)^2/1*^-12]}; Restrict the plotting area and multiply with 1000: data = Flatten[Table[fun, {x, 200, 300, 3}, {y, 200, 300, 3}], 1]*1000 ListPointPlot3D[data, PlotRange -> Full, ColorFunction -> "DarkRainbow"] ListDensityPlot[data, Mesh -> ...


1

This is not a proper answer. Rather, it provides some tools to handle the lists of tokens in other answers. Let jacobList = {"SelectNextExpression", "SelectPreviousExpression"}; I used the code below to merge the lists by belisarius (originalList), Vladimir (vladimirList) and myself (jacobList). You can set vladimirList = l, where l is defined in ...



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