The near-complete obviation of nulls is perhaps the most frequently- (and hilariously-) cited benefit of working in F#, as compared to C#. Nulls certainly still exist in F#, but as a practical matter it really is quite rare that they need to be considered explicitly within an all-F# codebase.
It turns out this cuts both ways. On those infrequent occasions where one does need to check for nulls, F# actually makes it surprisingly difficult to do so safely and efficiently.
In this post I’ve tried to aggregate some best practices and pitfalls, in the form of DOs and DON’Ts, for F# null-checking.
Working on the command line with Powershell, much of the time I have the luxury of dealing directly with rich .NET objects. If I need to sort, filter, or otherwise process cmdlet output, I have easy access to typed properties and methods right at the prompt.
Often, though, I’ll need to wrangle plain text, perhaps from a log file or the output of an executable. In these cases an intermediate step is required in order to extract the typed information (timestamps, substrings, numerical fields, etc) from the plain strings.
This comes up often enough that I whipped up a handy Powershell filter, ‘ro’ (for ‘regex object’), to make it easy:
For Christmas this year, I got myself a fun mathematical gift: a set of 10 non-transitive dice, namely Grime Dice! You can get your own set here. Behold their dicey splendor:
These dice possess the fascinating property that their winning relationships (in the sense of “winning” = “rolls a higher number > 50% of the time”) are non-transitive. i.e. if die A wins against die B, and die B wins against die C, it actually does *not* hold, in general, that die A wins against die C. In fact, die C might win against die A!
By now, most everyone is aware of Pi Day, celebrating the famous mathematical constant
\(\pi \approx 3.14159\)
on 3⁄14. On this day each year, students and math enthusiasts eat pie and engage in light-hearted
-related activities. Then there is e Day, a day for commemorating the equally-important-if-somewhat-less-famous constant
\(e \approx 2.71828\)
on 2⁄7. The activities are similar, though it’s less clear-cut what food one should eat (a high school teacher of mine insisted that the proper e Day food is waffles, evocative of the Cartesian coordinate system). Even events like Pi Approximation Day (22⁄7 in day/month format), and Mole Day (6:02 10⁄23) have gained enough momentum to warrant dedicatedresults from both Google and Bing.