19,838 reputation
14387
bio website
location
age
visits member for 2 years, 11 months
seen 19 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.


1d
answered ReplacePart equivalent for Associations
2d
answered Filtering Query Nested Data (Dataset and Association)
Dec
10
comment Error when implementing StartProcess[] in loops (Do, While, Table)
The problem with swapped stream names has been fixed in version 10.0.2.
Dec
10
revised Error when implementing StartProcess[] in loops (Do, While, Table)
noted that the swapped stream names have been fixed in version 10.0.2
Dec
8
comment Converting hierarchies of rules to associations
To see this all in action, constrast foo[2, foo[1], 3] /. e:foo[x__] /; (Print[e];True) :> fff[x] to Replace[foo[2, foo[1], 3], e:foo[x__] /; (Print[e]; True) :> fff[x], {0, Infinity}]
Dec
8
comment Converting hierarchies of rules to associations
We know that matching works from the outermost level inward from the documentation statement that after a match no further rules are tried on that part, or on any of its subparts. Example 1 matches foo heads only. As they have no subparts to skip, the inner foo is visited and replaced. Example 2 matches foo[x__] which does have subparts that are skipped, and we can see the inner foo subpart is left unchanged. Examples 3 and 4 give the same results as examples 1 and 2 respectively. Sow/reap tells us nothing here since the values are all being sown before replacement occurs.
Dec
8
answered Rearranging a Dataset
Dec
7
comment Unexpected result from StringReplace
The Details section of StringExpression explicitly, if cryptically, states that Except can be used to match either a single character or a string position. It also implicitly suggests that the only valid arguments are those patterns listed within the sections detailing classes of characters or positions in strings. Experimentation supports this interpretation. All of this requires a pretty close reading -- I would prefer more direct statements of these points within the documentation.
Dec
5
awarded  Nice Answer
Dec
5
revised Where is the old option TraceInternal->True?
added the update concerning the `SetStreamPosition` messages
Dec
5
answered Where is the old option TraceInternal->True?
Dec
4
comment Dataset Query with condition on two subsequent rows
+1 You could also replace 7 with SelectFirst[Length@# >= 2 &] to address it structurally.
Dec
4
comment Select last occurence of key in dataset
@alancalvitti To resolve name collisions, I usually choose one of two strategies. If the number of uses of a colliding name is small, then I just use the fully qualified name. If there are a large number of references, then I define a short alias instead. While I can think a few instances where I have had to deal with a function name collision, I can't think of a case where I have had to deal with colliding global variables. Global variable names tend to be very specialized.
Dec
1
answered How Can Notebook Know When it Called by Another Notebook?
Nov
24
awarded  Good Answer
Nov
24
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).
Nov
24
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.
Nov
24
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. :)
Nov
24
answered How to build this grid with less code?
Nov
24
comment TreePlot remove an arrow
For rotating the tree, see Can TreeForm be displayed “sideways”?.