Created
July 19, 2016 18:31
-
-
Save paulp/5bcef6daf9637d65501d5b019d764512 to your computer and use it in GitHub Desktop.
scala is bad.
This file contains hidden or 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
object Main { | |
val s1 = Set[BigDecimal](-4.872401723124452E9, 0, 1.1752011936438014, 8.696374707602505E17, -1.1752011936438014) | |
val s2 = Set[Double] (-4.872401723124452E9, 0, 1.1752011936438014, 8.696374707602505E17, -1.1752011936438014) | |
val s3: Set[BigDecimal] = s2 map (d => BigDecimal(d)) | |
def main(args: Array[String]): Unit = { | |
/* false */ println(s1 == s2) | |
/* true */ println(s1 == s3) | |
/* false */ println(s2 == s3) | |
/* true */ println(s1.toSeq.sorted == s2.toSeq.sorted) | |
/* true */ println(s1.toSeq.sorted == s3.toSeq.sorted) | |
/* true */ println(s2.toSeq.sorted == s3.toSeq.sorted) | |
/* true */ println("s1 forall: " + (s1 forall (x => s2 exists (y => x == y)))) | |
/* true */ println("s2 forall: " + (s2 forall (x => s1 exists (y => x == y)))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about using scastie, so people can see the results