public final class Natural
extends java.lang.Number
Modifier and Type | Field and Description |
---|---|
static F<Natural,F<Natural,Natural>> |
add
A function that adds two natural numbers.
|
static F<Natural,java.math.BigInteger> |
bigIntegerValue
A function that returns the BigInteger value of a given Natural.
|
static F<Natural,F<Natural,Natural>> |
divide
A function that divides its second argument by its first.
|
static F<Natural,F<Natural,V2<Natural>>> |
divmod
A function that divides its second argument by its first, yielding both the quotient and the remainder.
|
static F<java.math.BigInteger,Option<Natural>> |
fromBigInt
A function that returns the natural number equal to a given BigInteger
|
static F<Natural,F<Natural,Natural>> |
mod
A function that yields the remainder of division of its second argument by its first.
|
static F<Natural,F<Natural,Natural>> |
multiply
A function that multiplies a natural number by another.
|
static Natural |
ONE
The natural number one
|
static F<Natural,F<Natural,Option<Natural>>> |
subtract
A function that subtracts its first argument from its second.
|
static Natural |
ZERO
The natural number zero
|
Modifier and Type | Method and Description |
---|---|
Natural |
add(Natural n)
Add two natural numbers together.
|
java.math.BigInteger |
bigIntegerValue()
Return the BigInteger value of this natural number.
|
Natural |
divide(Natural n)
Divide a natural number by another.
|
V2<Natural> |
divmod(Natural n)
Divide a natural number by another yielding both the quotient and the remainder.
|
double |
doubleValue()
Return the double value of this natural number.
|
float |
floatValue()
Return the float value of this natural number.
|
int |
intValue()
Return the int value of this natural number.
|
long |
longValue()
Return the long value of this natural number.
|
Natural |
mod(Natural n)
Take the remainder of a natural number division.
|
Natural |
multiply(Natural n)
Multiply a natural number by another.
|
static Option<Natural> |
natural(java.math.BigInteger i)
Returns the natural number equal to the given BigInteger
|
static Option<Natural> |
natural(long i)
Returns the natural number equal to the given long
|
static F<Natural,Option<Natural>> |
pred_()
First-class predecessor function.
|
Option<Natural> |
pred()
Return the predecessor of this natural number
|
static Natural |
product(List<Natural> ns)
Takes the product of a list of natural numbers.
|
static Natural |
product(Stream<Natural> ns)
Takes the product of a stream of natural numbers.
|
Option<Natural> |
subtract(Natural n)
Subtract a natural number from another.
|
static F<Natural,Natural> |
succ_()
First-class successor function.
|
Natural |
succ()
Return the successor of this natural number
|
static Natural |
sum(List<Natural> ns)
Sums a list of natural numbers.
|
static Natural |
sum(Stream<Natural> ns)
Sums a stream of natural numbers.
|
public static final F<java.math.BigInteger,Option<Natural>> fromBigInt
public static final Natural ZERO
public static final Natural ONE
public static final F<Natural,F<Natural,Option<Natural>>> subtract
public static final F<Natural,F<Natural,Natural>> multiply
public static final F<Natural,F<Natural,Natural>> divide
public static final F<Natural,F<Natural,Natural>> mod
public static final F<Natural,F<Natural,V2<Natural>>> divmod
public static Option<Natural> natural(java.math.BigInteger i)
i
- A given BigIntegerpublic static Option<Natural> natural(long i)
i
- A given longpublic Natural succ()
public static F<Natural,Natural> succ_()
public Option<Natural> pred()
public static F<Natural,Option<Natural>> pred_()
public Natural add(Natural n)
n
- A natural number to add to this one.public Option<Natural> subtract(Natural n)
n
- A natural number to subtract from this one.public Natural multiply(Natural n)
n
- A natural number to multiply by this one.public Natural divide(Natural n)
n
- A natural number to divide this one by.public Natural mod(Natural n)
n
- A natural number to divide this one by.public V2<Natural> divmod(Natural n)
n
- A natural number to divide this one by.public java.math.BigInteger bigIntegerValue()
public long longValue()
longValue
in class java.lang.Number
public float floatValue()
floatValue
in class java.lang.Number
public double doubleValue()
doubleValue
in class java.lang.Number
public int intValue()
intValue
in class java.lang.Number
public static Natural sum(Stream<Natural> ns)
ns
- A stream of natural numbers.public static Natural product(Stream<Natural> ns)
ns
- A stream of natural numbers.public static Natural sum(List<Natural> ns)
ns
- A list of natural numbers.