Easier to understand random-color example

Used named functions rather than anonymous functions.