CanAddAndSubtract
A trait that extends CanAdd and provides additional functionality for types supporting both addition and subtraction operations. It introduces the ability to negate instances of type T and override the unary negation operator.
Type Parameters:
T: A type extendingStructurethat supports addition, subtraction, and negation operations with an implicitAdditiveCommutativeGroup[T]evidence.
Attributes
- Graph
-
- Supertypes
- Known subtypes
Members list
Value members
Abstract methods
Subtracts the given instance of type T from the current instance.
Subtracts the given instance of type T from the current instance.
This method computes the result of subtracting the that instance from the current instance by utilizing the properties of an additive commutative group defined for type T.
Value parameters
- that
-
the instance of type
Tto subtract from the current instance - using
-
evidence of an implicit
AdditiveCommutativeGroup[T]that provides the additive commutative group structure supporting subtraction
Attributes
- Returns
-
the resulting value of type
Tafter subtraction
Negates the current WholeNumber instance, producing its additive inverse.
Negates the current WholeNumber instance, producing its additive inverse.
Attributes
- Returns
-
The additive inverse of the current WholeNumber.
Inherited methods
Adds the given instance of the same type to this instance, leveraging the properties of an AdditiveCommutativeMonoid to ensure associativity, commutativity, and identity. CONSIDER keeping percentage if both are percentages. CONSIDER rewriting this in such a way that no exception will ever be thrown (use compiler to check, not runtime).
Adds the given instance of the same type to this instance, leveraging the properties of an AdditiveCommutativeMonoid to ensure associativity, commutativity, and identity. CONSIDER keeping percentage if both are percentages. CONSIDER rewriting this in such a way that no exception will ever be thrown (use compiler to check, not runtime).
Value parameters
- that
-
The instance of the same type to be added to this instance.
Attributes
- Returns
-
The result of adding this instance and the provided instance.
- Inherited from:
- CanAdd
Casts the current instance to the type parameter T of the enclosing Can trait.
Casts the current instance to the type parameter T of the enclosing Can trait.
This method performs a type-safe cast using the ClassTag to verify at runtime that the cast is valid. If the current instance cannot be cast to type T, an AlgebraException is thrown.
Attributes
- Returns
-
the current instance as an instance of type
T - Throws
-
AlgebraException
if the cast is invalid
- Inherited from:
- Can
Computes the additive inverse (negation) of an instance of type T.
Computes the additive inverse (negation) of an instance of type T.
Value parameters
- AdditiveCommutativeGroup[T]
-
an implicit instance of
AdditiveCommutativeGroupfor the typeT, providing the necessary additive group operations.
Attributes
- Returns
-
the negated value of the current instance as an instance of type
T. - Inherited from:
- CanNegate
Computes the addition of this object and the given Structure object using the additive properties of an AdditiveCommutativeMonoid. The operation returns an optional result where the addition succeeds if a valid transformation and combination can be performed.
Computes the addition of this object and the given Structure object using the additive properties of an AdditiveCommutativeMonoid. The operation returns an optional result where the addition succeeds if a valid transformation and combination can be performed.
CONSIDER eliminate this method and use with + instead.
Value parameters
- that
-
the
Structureobject to be added to this object.
Attributes
- Returns
-
an
Optioncontaining the result of the addition if successful, orNoneif the operation cannot be completed. - Inherited from:
- CanAdd