Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // add any two integer value
- def addInt(a: Int, b: Int): Int = a + b
- // add employe salary to their account balances
- def addMoneyMap(balances: Map[String, Money], salary: Map[String, Money]): Map[String, Money] = {
- balances.foldLeft(salaries){
- case (acc, (name, money)) =>
- acc + (name -> acc.get(name).map(addMoney(_ , money)).getOrElse(money))
- }
- }
Add Comment
Please, Sign In to add comment