Skip to content

Instantly share code, notes, and snippets.

@larsrh larsrh/demo1.scala
Last active Sep 14, 2018

Embed
What would you like to do?
LX Scala 2018/Scala Italy 2018 demo code: "Numeric programming with spire"
val cities1 = Map("Portugal" -> List("Lisbon"), "Spain" -> List("Madrid"))
val cities2 = Map("Portugal" -> List("Coimbra"))
cities1 |+| cities2
RingLaws[Int].ring.all.check()
RingLaws[Float].ring.all.check()
val score = r"5/7"
def twice[A : AdditiveMonoid](a: A) = a + a
twice(score)
twice(3)
twice(Map("Score" -> score))
score.toBigDecimal()
Real.pi
Real.pi.doubleValue()
Real.pi.toRational(1).toBigDecimal()
Real.pi.toRational(2).toBigDecimal()
Real.pi.toRational(4).toBigDecimal()
val score = r"5/7"
val confidence = score ± r"1/7"
confidence.intersects(r"3/4" ± r"1/8")
confidence.intersect(r"3/4" ± r"1/8")
import $ivy.`org.typelevel::spire:0.15.0`
import $ivy.`org.typelevel::spire-laws:0.15.0`
import spire._
import spire.algebra._
import spire.math._
import spire.implicits._
import spire.laws._
import spire.syntax.literals._
import org.scalacheck._
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.