18,173 reputation
13983
bio website
location
age
visits member for 2 years, 9 months
seen 5 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.


Sep
18
comment Applying a function to a Dataset column conditional on another slot's value
@TaliesinBeynon I believe this is a reference to the surprising behaviour of operator forms discussed here, here, and here. I don't have 10.0.1 yet, but I hear reports that only some of these have been addressed.
Sep
18
comment Advanced SQL-type select statements (filtering) on Datasets
@TaliesinBeynon OK, I'll spill a little bit into a second comment box :) It would be nice if there were a way to define some kind of macro facility for the existing descending operators so that common expressions could be named and parameterized.
Sep
18
comment Advanced SQL-type select statements (filtering) on Datasets
@TaliesinBeynon That's a good question, and this comment box feels very constraining :D Random thoughts: I think that ascending operators are pretty much covered since we have the full power of the language available to them. For descending operators, it would be interesting to come up with some kind of conditional syntax to be able to select a different operator based upon some computation. Given the nature of descending operators, especially with an eye to any future compilation to SQL et al, that syntax would have to strike a careful balance between expressiveness and compilability.
Sep
18
comment Tracking Initialization
@Kuba Yes. Please see the new variation using UpdateInterval.
Sep
18
revised Tracking Initialization
added the option to track from within the `DynamicModule`
Sep
18
answered Tracking Initialization
Sep
18
answered Bug with Initialization in DynamicModule?
Sep
17
revised Applying a function to a Dataset column conditional on another slot's value
added the note about Leonid's solution
Sep
17
comment Applying a function to a Dataset column conditional on another slot's value
@alancalvitti Okay, if we are talking about the known 10.0.0 bugs then I'm still disappointed but not quite as much :)
Sep
17
comment Applying a function to a Dataset column conditional on another slot's value
@alancalvitti I added your variation to my answer, thanks. I haven't got 10.0.1 yet, but I am quite disappointed if it has introduced new bugs into MapAt.
Sep
17
revised Applying a function to a Dataset column conditional on another slot's value
added the suggestion by @alancalvitti
Sep
17
comment DeleteMissing level spec confusion
@Mr.Wizard I have no strong opinion one way or another about whether this question should remain open. From the outside, all three questions appear to be a single bug as they all manifest in exactly the same fashion. From the inside (that is, from within the WRI implementation), it would seem that they are separate bugs. This is evidenced by the fact that at least one of them can be fixed independently of the others. Are the bugs independent, or was the fix incomplete? There is no way for us outsiders to discriminate these cases -- and I suspect the insiders find it difficult too :)
Sep
16
revised Applying a function to a Dataset column conditional on another slot's value
added 108 characters in body
Sep
16
answered Applying a function to a Dataset column conditional on another slot's value
Sep
16
comment have a function redefine itself as it maps through a list
Another localization option is to avoid using a pure function, e.g. Module[{f, i = 1}, f[x_] := x /. a :> i++; f] /@ {{a, a, i, a}}.
Sep
16
comment have a function redefine itself as it maps through a list
+1. Localizing i is quite difficult in this context. Block is not sufficient -- try it with the list {{a, a, i, a}}. The usual cure, Module, won't work here either due to inner scope renaming. It will take some gymnastics to localize i properly: Module[{i}, Module @@@ (Hold[{i = 1}, # /. a :> i++] &)]. @belisarius
Sep
16
comment Flatten command: matrix as second argument
@Tangshutao See the second FAQ on my profile.
Sep
14
comment Populate an upper triangular matrix from a vector of elements
@Tangshutao If I did that, it would place the burden of computing n on the caller and make upperTriangular[v, n] go inert if they got that calculation wrong. If we wanted only one definition, I would keep upperTriangular[n_] and merge the second into it by computing n within the Module. But the separate definitions support both the original use case as well as the precomputation of the transformation function by upperTriangulizer.
Sep
13
answered DeleteMissing level spec confusion
Sep
13
revised Populate an upper triangular matrix from a vector of elements
added the note about _Optional::opdef_