Skip to content

Instantly share code, notes, and snippets.

@Krasnyanskiy
Last active April 2, 2016 18:34
Show Gist options
  • Save Krasnyanskiy/f3b2674d3d4e9dd61b605377fa7cad0e to your computer and use it in GitHub Desktop.
Save Krasnyanskiy/f3b2674d3d4e9dd61b605377fa7cad0e to your computer and use it in GitHub Desktop.
-scala: comb-s
/**
* @author Alexander Krasniansky
*/
object Product extends App {
def cardinality(set: Set[_]) = set size
// ================= Set Intersection =================
val A = Set(1, 2, 3, 4, 5)
val B = Set(6, 7, 8, 9, 10)
val C = A intersect B
println(cardinality(C))
// ================= Cartesian Product =================
val D = for {x <- A; y <- B} yield (x, y)
println(D)
println(cardinality(D))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment