Advertisement
Guest User

Untitled

a guest
Jun 30th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.26 KB | None | 0 0
  1.   type Occurrences = List[(Char, Int)]
  2.  
  3.   def subtract(x: Occurrences, y: Occurrences): Occurrences = {
  4.     val map = y.toMap
  5.     x.foldRight(List[Char, Int]()){
  6.       case ((c, i), xs) if map.contains(c) => (c, 9) :: xs
  7.       case (_, xs) => xs
  8.     }
  9.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement