The number expression library has similar results, hitting about 2 seconds. Note that the a stays as a variable, as the expression string cannot inter-operate with lambdas.

Apart from light exercise, what have we learned?

Lambdas aren't terribly slow, in fact they are more or less comparable.

Also, as we saw yesterday, using lambdas means that our functions are mostly pure, which also means our code is memoisable.

Memoisation is a way of saving inputs and outputs in a table, every time we call the function we check whether we already have the result in the table or cache rather than computing the function repeatedly. This happens to coincide with the definition of pure functions.

Perhaps lambdas will really shine when memoised, because we can ensure less funny business with mutable global state interfering with our calculations, meaning we never have to worry whether our cache is out of date.