ExponentialIsCommutativeMonoid

com.phasmidsoftware.number.algebra.eager.Exponential.ExponentialIsCommutativeMonoid
object ExponentialIsCommutativeMonoid extends CommutativeMonoid[Exponential]

Provides an implicit implementation of a commutative group for the Exponential type, supporting group operations such as identity, combination, and inversion.

This allows Exponential objects to adhere to the algebraic structure of a commutative group, where the combine operation is associative and commutative, an identity element exists, and each element has an additive inverse.

Attributes

Graph
Supertypes
trait CommutativeMonoid[Exponential]
trait CommutativeSemigroup[Exponential]
trait Monoid[Exponential]
trait Semigroup[Exponential]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type

Members list

Value members

Concrete methods

Combines two Exponential instances by adding their respective value. NOTE that this is the equivalent of multiplying the corresponding (exponential) values. This method is associative and commutative, meaning that the order of the arguments does not matter. The identity element is the zero value, which is the neutral element for the addition operation.

Combines two Exponential instances by adding their respective value. NOTE that this is the equivalent of multiplying the corresponding (exponential) values. This method is associative and commutative, meaning that the order of the arguments does not matter. The identity element is the zero value, which is the neutral element for the addition operation.

Value parameters

x

the first Exponential to combine

y

the second Exponential to combine

Attributes

Returns

a new Exponential representing the sum of the value of the two provided Exponential instances

Note

Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the input types are not compatible.

Inherited methods

def combineAll(as: IterableOnce[Exponential]): Exponential

Given a sequence of as, sum them using the monoid and return the total.

Given a sequence of as, sum them using the monoid and return the total.

Example:

scala> import cats.kernel.instances.string._

scala> Monoid[String].combineAll(List("One ", "Two ", "Three"))
res0: String = One Two Three

scala> Monoid[String].combineAll(List.empty)
res1: String = ""

Attributes

Inherited from:
Monoid
override def combineAllOption(as: IterableOnce[Exponential]): Option[Exponential]

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).

Example:

scala> import cats.kernel.instances.string._

scala> Semigroup[String].combineAllOption(List("One ", "Two ", "Three"))
res0: Option[String] = Some(One Two Three)

scala> Semigroup[String].combineAllOption(List.empty)
res1: Option[String] = None

Attributes

Definition Classes
Monoid -> Semigroup
Inherited from:
Monoid
override def combineN(a: Exponential, n: Int): Exponential

Return a appended to itself n times.

Return a appended to itself n times.

Example:

scala> import cats.kernel.instances.string._

scala> Monoid[String].combineN("ha", 3)
res0: String = hahaha

scala> Monoid[String].combineN("ha", 0)
res1: String = ""

Attributes

Definition Classes
Monoid -> Semigroup
Inherited from:
Monoid
override def intercalate(middle: Exponential): CommutativeSemigroup[Exponential]

Between each pair of elements insert middle This name matches the term used in Foldable and Reducible and a similar Haskell function.

Between each pair of elements insert middle This name matches the term used in Foldable and Reducible and a similar Haskell function.

Attributes

Definition Classes
CommutativeSemigroup -> Semigroup
Inherited from:
CommutativeSemigroup
def isEmpty(a: Exponential)(implicit ev: Eq[Exponential]): Boolean

Tests if a is the identity.

Tests if a is the identity.

Example:

scala> import cats.kernel.instances.string._

scala> Monoid[String].isEmpty("")
res0: Boolean = true

scala> Monoid[String].isEmpty("something")
res1: Boolean = false

Attributes

Inherited from:
Monoid
override def reverse: CommutativeMonoid[Exponential]

return a semigroup that reverses the order so combine(a, b) == reverse.combine(b, a)

return a semigroup that reverses the order so combine(a, b) == reverse.combine(b, a)

Attributes

Definition Classes
CommutativeMonoid -> CommutativeSemigroup -> Monoid -> Semigroup
Inherited from:
CommutativeMonoid

Concrete fields

lazy val empty: Exponential

Provides the identity element for the Exponential group, representing a Exponential of zero value.

Provides the identity element for the Exponential group, representing a Exponential of zero value.

Attributes

Returns

a Exponential instance with zero value, acting as the identity element in the group structure.