Trying to learn some functional programming