As an alternative to understanding, we understand a solution based on filter and map :
def odd(x: Int) = x % 2 == 1 def boomBangs(xs: Seq[Int]) = xs filter odd map {i => if (i < 10) "BOOM!" else "BANG!"} boomBangs(3 :: 4 :: 5 :: 10 :: 11 :: 12 :: 13 :: Nil) // List(BOOM!, BOOM!, BANG!, BANG!)
Relationships are actually converted to expressions withFilter , map and flatMap compiler.
source share