functional programming of scala