fj.function.Longs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava Show documentation
Show all versions of functionaljava Show documentation
Functional Java is an open source library that supports closures for the Java programming language
package fj.function;
import fj.F;
import fj.F2;
import static fj.Function.curry;
import static fj.Semigroup.longAdditionSemigroup;
import static fj.Semigroup.longMultiplicationSemigroup;
import static java.lang.Math.abs;
/**
* Curried functions over Longs.
*
* @version %build.number%
*/
public final class Longs {
private Longs() {
throw new UnsupportedOperationException();
}
/**
* Curried Long addition.
*/
public static final F> add = longAdditionSemigroup.sum();
/**
* Curried Long multiplication.
*/
public static final F> multiply = longMultiplicationSemigroup.sum();
/**
* Curried Long subtraction.
*/
public static final F> subtract = curry(new F2() {
public Long f(final Long x, final Long y) {
return x - y;
}
});
/**
* Negation.
*/
public static final F negate = new F() {
public Long f(final Long x) {
return x * -1L;
}
};
/**
* Absolute value.
*/
public static final F abs = new F() {
public Long f(final Long x) {
return abs(x);
}
};
/**
* Remainder.
*/
public static final F> remainder = curry(new F2() {
public Long f(final Long a, final Long b) {
return a % b;
}
});
}