20,133 reputation
14388
bio website
location
age
visits member for 2 years, 11 months
seen 10 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.


Jul
30
comment What is the natural way of using Dataset to get a FittedModel?
@RunnyKine Indeed ;) Leftovers from one of the other 50 variations I tried, no doubt. Removed.
Jul
30
revised What is the natural way of using Dataset to get a FittedModel?
removed unnecessary quotes
Jul
30
comment How to insert zero counts uniformly with Dataset Counts query
I posted a question about the possible bug.
Jul
30
asked Possible bug involving Dataset/Query and RightComposition
Jul
30
answered Possible bug involving Dataset/Query and RightComposition
Jul
29
comment How to insert zero counts uniformly with Dataset Counts query
The difference between the /* behaviour between raw2 vs raw is strange and possibly a bug. In the meantime, try the supposedly equivalent expression raw2[Values /* KeyUnion, Counts][All, All, # /. _Missing -> 0 &]. If you wish to pursue the /* difference, I suggest a new question (which I presently cannot answer).
Jul
29
comment Get the last line from each of a large number of files, transform them, and write all results to a single new file
@librik Thanks, that never occurred to me. I've added a note to that effect to my response.
Jul
29
revised Get the last line from each of a large number of files, transform them, and write all results to a single new file
added the note about using a negative stream position
Jul
29
answered What is the natural way of using Dataset to get a FittedModel?
Jul
29
revised How to insert zero counts uniformly with Dataset Counts query
add the example query for working from the raw data
Jul
29
revised How to insert zero counts uniformly with Dataset Counts query
added the single-pass version of the replacement query
Jul
29
answered How to insert zero counts uniformly with Dataset Counts query
Jul
27
answered Changing Values in an Association using Map
Jul
27
comment How to get a list of all expressions in a notebook matching a certain pattern?
@VladimirReshetnikov The $ prefix is purely stylistic. I use it so that global variable names stand out. I've been burnt too many times when I forget that x is bound to something, so I use $x instead. Mathematica uses the same convention for built-in globals, except those variables start with a capital letter after the $.
Jul
27
comment How to get a list of all expressions in a notebook matching a certain pattern?
@Mr.Wizard Thanks for the comments. (1) Done. (2) Agreed, I just have the habit of using the long form. (3) It is not common, but I have seen it. It is similar to the Missing idiom. My choice was arbitrary and I was attempting to convey the notion of failure. The wrapper is strictly speaking not necessary -- the only requirement is that the head is different from Hold so that failures can be distinguished. Cell would be good enough. I leave it to the taste of the user.
Jul
27
revised How to get a list of all expressions in a notebook matching a certain pattern?
moved the caution about `ToExpression` from a comment to the main body
Jul
27
answered How to get a list of all expressions in a notebook matching a certain pattern?
Jul
27
answered Dataset with no members
Jul
27
comment Error changing Dataset using Part
Examples such as these are sure to increase the fun factor for the WRI employees working to compile the Query language into SQL ;)
Jul
27
answered Error changing Dataset using Part