8-Queens in 8 Lines

Brushing up on “whiteboard coding” for internal interviews… Inspired by Hal Ableson’s streams-based solution to this old classic in the SICP lectures, here’s a pretty concise n-Queens solution:   let rec Solutions n board size = seq { // board is (x,y) tuple list of queens      let safe board (x,y) = // is particular…

1

Ants

Gram’s blog has been pretty fun to follow. Like with Project Euler, I constantly want to implement each thing he talks about (e.g. Monadic Coconuts, Towers of Hanoi). Here now is “The Wondering Ant”: open System.Drawing open System.Windows.Forms   let rec ant (x, y) (dx, dy) g i =     let g’ = Array2D.mapi (fun x’…

0

TinyRPN Calculator

It’s fun dorking around with the HP 41CX emulator on the iPhone. It’s a near-perfect rendition. I forgot how much I loved RPN calculators. The 48GX looks even more interesting with Reverse Polish Lisp but I haven’t figured out how to use it yet. The 41CX, on the other hand, is an old friend. 🙂…

1

Babbage’s Difference Engine

  Babbage’s Difference Engine is pretty fascinating. I had wanted to go see the one on display at the Computer History Museum in Mountain View, but now Nathan Myhrvold has the thing back in his living room! Maybe I’ll build one out of Legos to keep in my office.   The physical engineering is amazing…

0

The Lambda Calculus

Mads Torgersen’s post the other day was very cool! The first time I really understood Lambda Calculus was from this little 8-page paper. Relating it to Scheme made it stick for me. After reading Dr. T’s post I was just now having some fun playing with it in Scheme and couldn’t resist making a post…

3