Guest User

Untitled

a guest
Apr 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. // add any two integer value
  2. def addInt(a: Int, b: Int): Int = a + b
  3.  
  4. // add employe salary to their account balances
  5. def addMoneyMap(balances: Map[String, Money], salary: Map[String, Money]): Map[String, Money] = {
  6. balances.foldLeft(salaries){
  7. case (acc, (name, money)) =>
  8. acc + (name -> acc.get(name).map(addMoney(_ , money)).getOrElse(money))
  9. }
  10. }
Add Comment
Please, Sign In to add comment