Category Archives: Mathematics

On closed range boundaries

Programmers often need to talk about ranges of values (whether or not the language at hand supports the concept explicitly). For example, given the Java array String[] streetLines = new String[3]; an index i must satisfy 0 ≤ i < 3 (in normal Mathematical notation) or 0 <= i && i < 3 (in Java [...]

“Linguistics” vs. Mathematics?

I happened across an interesting post on Chris Okasaki’s blog, titled Less than vs Greater than. Let me suggest that you read it before continuing here. I would paraphrase his point about errors he observed in students’ programs as follows: A student who writes an expression such as expL < expR often appears to lock [...]

Design by proof

The idea of proving programs correct has been around (and hotly debated) for roughly forty years. The irony is that some proof advocates anticipated by more than thirty years what the agile advocates are now saying: Designing with verification in mind improves the quality of the resulting design. To be even more specific, compare these [...]

A composite function

The previous post began working with problem 3 from Project Euler. The allFactors function produced a list of the prime factors of its argument (all occurrences of all prime factors), such as: scala> val nums = allFactors(96000) nums: List[Long] = List(5, 5, 5, 3, 2, 2, 2, 2, 2, 2, 2, 2) It would be [...]

Prime time programming

“The purpose of computing is insight, not numbers.” – Richard Hamming My interest in pursuing this series is not in the numbers, nor the Mathematics, but in the process of constructing reliable solutions. I’m also learning Scala, and want to understand how its hybrid OO/FP nature may offer fresh perspectives to my pursuit of programming. [...]

Go with the flow

The second problem from Project Euler asks for the sum of the even Fibonacci numbers which are at most 4,000,000. An aside on the numbers The problem’s description of the Fibonacci sequence is flawed (or at least non-standard); the problem statement begins the sequence with 1 and 2, showing the first 10 terms as: 1, [...]

The burden of FP

A rude awakening… When the fire alarm sounded at about 2:00 AM, I didn’t want to think about electrical engineering, hydrology, or locksmithing. I wanted a quick fix. The tiniest of pinhole leaks in the attic water heater drain line had released a fine mist, some of which escaped the footprint of the catch pan. [...]

Follow

Get every new post delivered to your Inbox.