All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ceylon.language.Invertible.ceylon Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
"Abstraction of [[additive|Summable]] numeric types which 
 support a unary operation `-x` producing the additive
 inverse of `x`. Every `Invertible` type supports a binary 
 subtraction operation `x-y`.
 
     Integer negativeOne = -1;
     Float delta = x-y;
 
 A concrete class that implements this interface should be a 
 mathematical _group_. That is, it should have an additive 
 identity, denoted `0`, and satisfy:
 
 - `0+x == x+0 == x`
 - `x + -x == 0`
 
 Subtraction must be defined so that it is consistent with
 the additive inverse:
 
 - `x - y == x + -y`"
see (`class Integer`, `class Float`)
by ("Gavin")
tagged("Numbers")
shared interface Invertible of Other
        satisfies Summable
    given Other satisfies Invertible {
    
    "The additive inverse of this value."
    since("1.1.0")
    shared formal Other negated;
    
    "The difference between this number and the given 
     number. Must produce the value `x + -y`."
    since("1.1.0")
    shared default Other minus(Other other) => this + -other;
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy