19,333 reputation
14386
bio website
location
age
visits member for 2 years, 10 months
seen 14 hours ago

Frequently Asked Questions

WReach? Is that connected to WRI somehow?

The "WR" in my name has nothing to do with the company that develops Mathematica. It is just a coincidence.

Why do you start all your global variable names with $?

I use dollar signs for ad hoc global variables because I have been bitten too many times by accidentally assigning an own-value to a symbol that I happen to use, for example, in a symbolic equation. So I am in the habit of writing $x instead of x. I stick to that convention even for longer symbols like $initialUrl. Just like the regular symbol convention, Mathematica's predefined global symbols all start with a capital letter after the $. My ad hoc symbols always start with a lower case letter, so there is no conflict.

Why do you put semicolons and commas at the beginning of the line instead of at the end like a normal person?

I don't think of it that way. Rather, I switch from horizontal to vertical layout when a single expression is too long to fit on one line. This has the interesting side-effect of making the important delimiters stand out and line up. I first ran into this practice in the SQL community. SQL "programs" have the unpleasant property that they must be written as a single statement -- even if that statement is a hundred lines long (or more!). Sometimes Mathematica expressions share that property.


18h
comment What quantity is this “length” called?
@Artes I do not understand the relevance of your link. Please explain.
2d
comment Injecting list of controls into manipulate
V10.0.2? :( I'm afraid I am not aware of a reliable fix. See the chat for another variation of your answer (but it is also flakey on V10).
2d
comment Injecting list of controls into manipulate
+1 This works well on V9... but for me under V10.0.1 on Win7 64 bit it issues many error messages, apparently due to this bug.
2d
comment How to build this grid with less code?
@MikeHoneychurch I abandoned my first solution because your post got there first. Now I see that my second solution is much like your edit. Oh well, them's the MSE breaks. :)
2d
comment TreePlot remove an arrow
For rotating the tree, see Can TreeForm be displayed “sideways”?.
2d
comment TreePlot remove an arrow
You have some extra braces in your replacement rules. Try this instead: {"p2a" | "p2b" | "p2c" -> "p2", "p3a" | "p3b" -> "p3"}
2d
comment TreePlot remove an arrow
In the desired plot mock-up, the upper "p2" node is terminal while the lower "p2" node has an edge to "Sp21". There is not enough information from the edge list alone to infer this output. In order to produce the output automatically, we will either need access to the required additional information, or we must adjust the desired output so that the edge between "p2" and "Sp21` is repeated in both locations.
Nov
21
comment Camel hump string split
@alancalvitti See the new section concerning digit characters. I'm afraid that the Mathematica symbolic string pattern syntax does not yet fully support all of the functionality in PCRE regular expressions. I agree that they are so cryptic as to be "write only".
Nov
20
comment Camel hump string split
Alas, the two dots are not quite enough for the abbreviations. Notice how "AASTriangle" is not split up. It doesn't detract from a good answer, though.
Nov
19
comment Installing LinkSnooper on Windows
@FredSimons You say that you are on 32-bit Windows, but the LinkSnooper command you show references the 64-bit Java directory Windows-x86-64. Does it work if you change that to the 32-bit directory Windows instead?
Nov
17
comment String pattern defined by number of characters
I have added the section about recursive patterns.
Nov
17
comment String pattern defined by number of characters
@Aisamu There is no direct equivalent in Mathematica's native string pattern syntax. It is probably possible to achieve a similar result using StringCases[s, $patt] where $patt is self-referential. The following pattern comes close, but it fails to preserve proper backtracking: $patt = "b" | "c" | ("a" ~~ (s___ /; StringMatchQ[s, $patt]) ~~ "d"). Even if it worked, it entails an evaluator callback from the PCRE engine for every potential match -- probably more trouble than it is worth.
Nov
11
comment Pattern matching: Times[a_] vs Times[a__]
@ShutaoTang The Internal package is undocumented, and we use its features at our own risk since it carries no guarantees and could be withdrawn at any time. As the name implies, it is used internally by the Mathematica implementation. There is no official documentation on this package, but this forum is rapidly becoming the repository for the collective findings of the community -- whether about Internal or many of the other undocumented features. And even the documented ones too :)
Nov
11
comment Select last occurence of key in dataset
@Lea As to the dollar sign in $dataset, see the second FAQ in my profile.
Nov
8
comment Using 0 to create new columns in a list with Part
@AlexeyPopkov Okay, okay... A New Kind of Map/Apply = A New Kind of Maple ;D
Nov
8
comment Copy/Paste of quoted text crashing Mathematica 10?
I can reproduce the crash on V10.0.1, Windows 7, 64-bit.
Nov
8
comment Using 0 to create new columns in a list with Part
A New Kind of Map :)
Nov
6
comment Error changing Dataset using Part
@ArgentoSapiens I have no current information about this. My glib comment was based upon the fact that pre-release versions of the V10 documentation contained extensive references to such capability. Those references were withdrawn very late, just before the official V10 release. I speculate that the functionality under discussion in the question would (or did) prove to be challenging to support across multiple back-end technologies.
Nov
4
comment Built-in way to convert Integer to Ordinal String
+1 It uses an undocumented internal function like this: SpokenStringDump`SpeakOrdinal[1] returning "1st". You might have to reference the symbol Speak first to make sure that the package is auto-loaded.
Oct
28
comment How to track Part of Symbol or How to symbolize Parts of Symbol without copying data
Is there any reason why you cannot define test3 := test2[[1]] and then use h[test3]?