Semiring

trait Semiring[@specialized(Int, Long, Float, Double) A] extends AdditiveCommutativeMonoid[A] with MultiplicativeSemigroup[A]

Semiring consists of:

Semiring consists of:

  • a commutative monoid for addition (+)
  • a semigroup for multiplication (*)

Alternately, a Semiring can be thought of as a ring without a multiplicative identity or an additive inverse.

A Semiring with an additive inverse (-) is a Rng. A Semiring with a multiplicative identity (1) is a Rig. A Semiring with both of those is a Ring.

Companion
object
trait Serializable
class Any
class MapSemiring[K, V]
class SetSemiring[A]
trait BoolRing[A]
trait Field[A]
trait BoolRng[A]
class SetBoolRng[A]
trait Rig[A]
trait Ring[A]
trait Rng[A]

Value members

Inherited methods

override def additive: CommutativeMonoid[A]
def isZero(a: A)(ev: Eq[A]): Boolean

Tests if a is zero.

Tests if a is zero.

Inherited from
AdditiveMonoid
def multiplicative: Semigroup[A]
def plus(x: A, y: A): A
Inherited from
AdditiveSemigroup
def pow(a: A, n: Int): A
def sum(as: IterableOnce[A]): A

Given a sequence of as, compute the sum.

Given a sequence of as, compute the sum.

Inherited from
AdditiveMonoid
override def sumN(a: A, n: Int): A
Definition Classes
Inherited from
AdditiveMonoid
def times(x: A, y: A): A
def tryProduct(as: IterableOnce[A]): Option[A]

Given a sequence of as, combine them and return the total.

Given a sequence of as, combine them and return the total.

If the sequence is empty, returns None. Otherwise, returns Some(total).

Inherited from
MultiplicativeSemigroup
override def trySum(as: IterableOnce[A]): Option[A]
Definition Classes
Inherited from
AdditiveMonoid
def zero: A
Inherited from
AdditiveMonoid