Skip to content

Instantly share code, notes, and snippets.

@codesurf42
Created April 16, 2015 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codesurf42/e63ff31753f76c69984c to your computer and use it in GitHub Desktop.
Save codesurf42/e63ff31753f76c69984c to your computer and use it in GitHub Desktop.
// case class Rel3(id: Int, vals: Option[Map[String, Set[Int]]])
val setm1 = Map(1 -> Some(Map("a" -> Set(1,2))))
val setm2 = Map(1 -> Some(Map("a" -> Set(2,3))))
val setm3 = Map(1 -> None)
val setm4 = Map(2 -> Some(Map("b" -> Set(5,6))))
val all = Set(setm1, setm2, setm3, setm4)
import scalaz._
import Scalaz._
all.reduce(_ |+| _)
// res0: scala.collection.immutable.Map[Int,Option[scala.collection.immutable.Map[String,scala.collection.immutable.Set[Int]]]] = Map(2 -> Some(Map(b -> Set(5, 6))), 1 -> Some(Map(a -> Set(1, 2, 3))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment