Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.21 KB | None | 0 0
  1. // given that lst is a list of Option tuples
  2.  
  3. val result = lst map {
  4.   case (Some(x), None   ) => x
  5.   case (None   , Some(y)) => 0 - y
  6.   case (Some(x), Some(y)) => x - y
  7.   case _                  => 0
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement