Archives for February 2009

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, [...]

Erlang surprises me.

I recently wanted to calculate some binomial coefficients in Erlang, and so needed an implementation of the factorial function. No problem. The factorial function is the canonical illustration of how to define a recursive function in Erlang. It goes something like this: fac(0) -> 1; fac(N) -> N * fac(N-1). I have to confess that [...]