functional programming principles in scala