scala functional programming