18,183 reputation
14083
bio website
location
age
visits member for 2 years, 9 months
seen 8 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
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]?
Oct
23
comment Accessing an API (made in the Wolfram Cloud) using a standalone application
When you access the URL in LiveCode, does the result contain any useful diagnostic information?
Oct
21
comment Listable functions thread over Associations; is this documented?
Speak of the devil... ACL just ran into this one again.
Oct
16
comment Listable functions thread over Associations; is this documented?
@Mr.Wizard This is the subject of one of my unposted responses ;D In brief, an example is that Query execution is sensitive to the TypeSystem data types inferred for Dataset elements. Those data types are presently inferred using heuristic methods, with magic threshold numbers relating to tuple sizes, key types and value types. This leads to surprising behaviour sometimes -- mostly for display, but sometimes for execution as well (the subject of my wayward post, which may never become fit enough to publish).
Oct
16
comment Listable functions thread over Associations; is this documented?
I have mixed feelings about this whole Association-masquerading-as-a-list business. On the one hand, I can see the benefits for interactive, ad hoc use. But I also fear that the non-determinism it introduces is a fertile source for bugs in library code. I have the same misgivings about the heuristics in Dataset/Query.
Oct
15
comment How can I evaluate only a single step of a recursive function?
Related question: How do I evaluate only one step of an expression? Mr.Wizard's answer is particularly nifty, although it won't work unmodified for the present question due to the vagaries as to what exactly constitutes "one step".
Oct
14
comment Odd problem with Module
If you have the Suggestions Bar turned on, does it make any difference if you turn it off? There have been reports of the Suggestions Bar mangling output.
Oct
13
comment Error when implementing StartProcess[] in loops (Do, While, Table)
+1. With respect to the stream names... I would agree if the stream names were simply "Input" and "Output". But I would argue that the qualifier Standard in "StandardInput" implies that it is being seen from the perspective of the process. After all, Mathematica's own stdin and stdout streams play no role here (i.e. brand new streams are created for the connection). However, what is done is done. It would be harmful to change it now. Perhaps it would make a fine addition to the Possible Issues section of the documentation :)
Oct
12
comment How can I determine the Parameters of URLFetch?
Related question: How to manipulate web pages on Mathematica?.
Oct
11
comment Error when implementing StartProcess[] in loops (Do, While, Table)
Note: I tested this on Windows 7, which exhibited the problem as well albeit at a much higher iteration count. I expect the solution to be the same on MacOSX, but I am not in a position to test it directly myself at the moment.
Oct
5
comment Replacing columns of a matrix with zeros
+1 If the OP's goal is to leave everything in the original code unchanged except m | n, then I suggest zeroColumns[mat_, m_ ;; n_] := ReplacePart[mat, {_, i_ /; m <= i <= n} -> 0].
Oct
1
comment How a novice user better understand the Q/A
You might find this wiki question useful, especially this answer and this answer.
Sep
29
comment Is there a comprehensive list of functions with V10 operator forms?
@RunnyKine Good idea. Done.
Sep
26
comment Why does my dataset lose its typesetting when I add columns?
The impact of type inference upon typesetting is discussed in detail here. There might be enough information there for the present question to be considered a duplicate.
Sep
24
comment How to replace the first occurance in an expression instead of replacing all?
+1 With version 10, we can use FirstPosition, e.g. HoldForm[x + 2 + 4 + x] // ReplacePart[#, FirstPosition[#, x] -> 4] &.
Sep
22
comment Elementwise operation, part deux
The implementation of generators is explored in this question. But if you are finding Do to be non-performant then you'll really hate the solution proposed there :)
Sep
20
comment How to “Copy as Unicode” from a Notebook?
@Mr.Wizard I spent a couple of hours today trying to fulfill the request, but failed. I kept hitting race conditions in re-entrant front-end calls while trying to hook up the context menu. This is because the only way I know how recover the text selection involves a front-end call, and the menu item invocation is already a front-end call. I can't really spend more time on it right now, so if anyone wants to incorporate uniclip into another answer that adds menu items and shortcut keys, feel free.
Sep
18
comment DeleteMissing level spec confusion
DOH! I completely missed that DeleteMissing was on the list of descending operators. Another way to convert a descending operator to ascending is like this: #& /* DeleteMissing. Note that Identity /* DeleteMissing will not do the job as the Identity operator is optimized out (it is effectively on the list of descending operators). In context: titanic[GroupBy@Key@"class", #& /* DeleteMissing, "age"].
Sep
18
comment DeleteMissing level spec confusion
@alancalvitti Please transfer the "accept" to Taliesin's answer. I will then delete this response as it presents an incorrect analysis.
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.