Binary Clock in 88 Characters

soranclock.gif
You’ll have to excuse me captain, I have an appointment with eternity, and I don’t want to be late.
— Dr. Tolian Soran

I find computer-science fictional interfaces e.g. alien clocks, rather exquisite. The timepiece above is a favorite of mine. The countdown graphic is displayed on the villain's tri-lithium missile launching platform in the movie Star Trek Generations. A number of fun blogs have surfaced recently that catalogue and explore various sci-ware interfaces from movies. Here's a few good ones: fakeui, access, movie code. Anyways, I had a free hour so I went and coded up an iPhone app for a clock that tells time in a user supplied base.

binaryclock.gif
examplebinary.gif

If you've never heard of a binary clock it's really simple. The example above on the right is counting seconds from 12:01 to 12:02. Here the columns correspond to the six decimal numbers h, h, m, m, s, s in base two (from left to right). Now, sadly the c-source would never fit into one small blog post and in the end, hundreds of lines of code were needed - lo the inelegance of the Objective-C language. But functional languages allow for breathtaking brevity, instead of over 100 lines, we use under 100 characters!  Here's that 1-liner:

Screen Shot 2014-02-22 at 3.32.37 PM.png

This generates the binary clock above on the left (rows are h, m, s in binary from top to bottom).  Of course, this isn't deployable code, yet... In future versions of Mathematica, as it is strongly typed, the kernel may be able to use clang to transform the expression into proper objective-c for iOS deployment (but that's just my pipe-dream).