Programming as a mathematical exercise