Ho ho ho! It’s the day after Christmas, and hopefully everyone has some snazzy new toys to play with. But just in case Santa left you a lump of coal (“… little Billy used mutable state this year …”), don’t pout, don’t cry, I’ve got you covered. My gift for all the naughty F# developers out there: a mini-framework for imperative-style looping in F#, adding the functionality of “break,” “continue,” and “return,” along with the ability to nest loops down to programmatic depth.
Continuing the recent theme of awesome .NET development news, a blog post from Thursday by the .NET team provided more details on the platform’s future, “.NET Core.”
The ensuing comment thread on Hacker News had some nice F# discussion. One commenter, though, was not a huge fan, and in particular lamented perceived limitations in the F# units of measure feature:
This isn’t too hard to code up, using perhaps a recursive function to represent
\(x_i\)
. With normal double-precision floats, as
\(i\)
increases, the result converges neatly toward 100. Super!
Unfortunately, 100 is not even close to the right answer. This recurrence actually converges to 5.
How computationally expensive are various fundamental floating point mathematical operations? Here’s a quick and dirty benchmark, which, although surely quite naive, seems to capture the rough relative cost of a few operations.
I poked around the code and tested it a bit myself, and figured I would take up the author’s call for feedback. Comments on the original blog are locked down, so I’ve written up my results here, instead.