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

Monadic Piles of Coconuts

After reading the “coconut” problem over on my friend’s blog, I thought it would be fun to solve it with a silly brute force approach. First, go read his post and then come back here. let take n =     let m = n – 1 // give one to the monkey     if m…

0

Towers of Hanoi

A friend of mine is starting a pretty fun looking math blog. His first post is on Towers of Hanoi. I’m sure he’ll tackle it with some slick mathematics, but my usual M.O. is to convert everything to code. I remember this “Hello Recursive World” from SICP in Scheme; looks better in F#: let rec hanoi…

0