Created
October 31, 2013 19:37
-
-
Save davidandrzej/7255536 to your computer and use it in GitHub Desktop.
Get union of all keys from a collection of Maps, the scalaz way.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz._, Scalaz._ | |
val data = Vector(Map(1 -> "a", 2 -> "b"), Map(2 -> "c", 3 -> "d")) | |
data.foldMap(_.keys.toSet) | |
// res0: scala.collection.immutable.Set[Int] = Set(1, 2, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment