Skip to content

Instantly share code, notes, and snippets.

@paulp
Created July 19, 2016 18:31
Show Gist options
  • Save paulp/5bcef6daf9637d65501d5b019d764512 to your computer and use it in GitHub Desktop.
Save paulp/5bcef6daf9637d65501d5b019d764512 to your computer and use it in GitHub Desktop.
scala is bad.
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))))
}
}
@nafg
Copy link

nafg commented Jul 20, 2016

How about using scastie, so people can see the results

@smoothdeveloper
Copy link

@nafg I get actually different results in scastie

http://scastie.org/21270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment