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 […]

## Archives for mathematica

### Rebinding Mathematica keys

Out of the box, Mathematica expects the user to press the SHIFT-RETURN to trigger the evaluation of an expression. Because of my hard-wired emacs reflexes, I frequently type CONTROL-RETURN instead. Today I finally did something about that. I rebound the SHIFT-RETURN sequence. Mathematica does not make that easy to do. I found nothing in the […]

### Too lazy to flip coins

I was helping my daughter with some math homework; one of the problems was to flip three coins and tabulate the number of heads over the course of eighty trials. This struck me as excessively tedious, so I suggested we write a computer simulation instead. Here it is, in its full glory: coin := Random[Integer, […]

### x + x = 2x

This post is the second in a series. The first is here. The plan for this post is to introduce just enough notation to define some functions in the Mathematica language, and then use Mathematica to solve a not-entirely-trivial problem. The central idiom in functional programming is applying a function f to an argument x. […]

### The unknown functional language

Functional languages are experiencing something of a renaissance, or so I gather from reading reddit and the blogs. I have been known to dabble in lisp, erlang, and haskell. Each is beautiful language in its own way. But when I actually want to get something done, not just play, I turn to either python or […]

### Euler 100

Euler Project problems can be addictive. This one gave me fits. If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, P(BB) = (15/21)×(14/20) = 1/2. The next such arrangement, […]

### Euler 183

I have not worked a Euler Project problem in some time. Here’s problem 183: Let N be a positive integer and let N be split into k equal parts, r = N/k, so that N = r + r + … + r. Let P be the product of these parts, P = r × […]