ぶろぐ

日記です

join ?


// import scalaz
// list
scala> val xs = List( List(1,2,3), List(4,5,6) )
xs: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))

scala> xs.flatten
res9: List[Int] = List(1, 2, 3, 4, 5, 6)

scala> xs.join
res10: List[Int] = List(1, 2, 3, 4, 5, 6)

// option
scala> val oi: Option[Option[Int]] = Some(Some(1))
oi: Option[Option[Int]] = Some(Some(1))

scala> oi.flatten
res11: Option[Int] = Some(1)

scala> oi.join
res12: Option[Int] = Some(1)