|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Number
fj.data.Natural
public class Natural
Represents a natural number (zero, one, two, etc.)
Field Summary | |
---|---|
static F<Natural,F<Natural,Natural>> |
add
A function that adds two natural numbers. |
static F<Natural,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<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 |
Method Summary | |
---|---|
Natural |
add(Natural n)
Add two natural numbers together. |
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(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. |
Methods inherited from class java.lang.Number |
---|
byteValue, shortValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final F<BigInteger,Option<Natural>> fromBigInt
public static final Natural ZERO
public static final Natural ONE
public static final F<Natural,F<Natural,Natural>> add
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 final F<Natural,BigInteger> bigIntegerValue
Method Detail |
---|
public static Option<Natural> natural(BigInteger i)
i
- A given BigInteger
public static Option<Natural> natural(long i)
i
- A given long
public 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 BigInteger bigIntegerValue()
public long longValue()
longValue
in class Number
public float floatValue()
floatValue
in class Number
public double doubleValue()
doubleValue
in class Number
public int intValue()
intValue
in class 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.
public static Natural product(List<Natural> ns)
ns
- A list of natural numbers.
|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |