My Mailbag
February 7, 2020
I had two interesting emails from readers this week. I’ll discuss both of them, but suppress the names of the writers; they can identify themselves in the comments below if they wish.
One writer saw Johnny Ball’s video about Russian Multiplication on Numberphile and suggested it would make a good exercise. Indeed it would; in fact, we have already done it twice ([1] [2]).
Another writer suggested that the compose
function in the Standard Prelude should return the identity function if called with no arguments, rather than reporting an error. That is, of course, correct; my apologies for the bug.
Your task is to write programs to perform russian multiplication and compose functions, as suggested above. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Should compose with no arguments return a function like (lambda args (apply values args))?
Here’s a solution in Python.
Output: