May 2009
3 posts
Rebuilding
I’ve lost tons of work in the past in almost every way imaginable, from melted or crushed hard disks to raid failures and unreliable hosts. I thought redundancy would save me, but these failures always seem to happen in pairs. I could fill a graveyard with all the work I’ve lost.
But I’m not gonig to let this get me down. I can still remember how I made most of those old...
Reduce by Any Other Name
One of my favorite functions is `reduce`. It’s the perfect way to represent anything like sum, product, factorial, reverse, that walks along a list accumulating the values it finds. Unfortunately, it’s hard to share my love of reduce when every language calls it something different. Observe:
# Python - reduce # reduce(function, iterable[, initializer]) def factorial(n): return...
Board Game Abstraction
How would you model a board game in a sql database? I’ve been overthinking this. I’d probably have a Game model to keep track of whose turn it is, with a lot of Pieces associated with it. But that’s obvious.
To be totally generic, a Piece could consist of string:kind, string:space, and string:color. But what if you were playing a game like chess with a 2D board? You could...