Archives for May 2011

map, mapp, and mapc

In a 1988 paper called Algebraic Identities for Program Calculation, Richard Bird wrote: Probably the most useful law about map is the fact that it distributes over functional composition: (map f) . (map g) = map (f . g) Bird’s paper predates Haskell, and instead uses a language called Miranda, but Haskell later adopted very […]

Monty Hall problem

There is currently an active discussion of the Monty Hall problem on the Clojure discussion group. The discussion centers on the simulation of the problem; here I want to look at it from first principles. The problem is actually an easy one to reason about when looked at from the right perspective. Here is how […]

The transpose function

I am going to discuss a function I think belongs in the Clojure core language. The function is called transpose. It is defined as follows. (defn transpose [xs] (apply map vector xs)) Here is what it does: user> (def m [ [‘a ‘b ‘c ‘d] [1 2 3 4] ]) #’user/m user> m [[a b […]

Synergy, ftw

These are some notes on running Synergy over an ssh tunnel. The problem: I use two computers at work. The one named Beavis runs Ubuntu, the other, named d73649, runs Win7. Each has its own monitor, mouse, and keyboard, but I prefer to use a single mouse and keyboard as much as possible. Synergy is […]

Sow the wind, reap the whirlwind

At the most recent meeting of TriClojure, I had the pleasure of chatting with Michael Fogus, one of the authors of The Joy of Clojure. I mentioned that I had done some Mathematica (Mma) programming, and Michael asked me about a couple of Mma constructs called Sow and Reap. Sow and Reap are always used […]