forked from functionaljava/functionaljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongs.java
More file actions
66 lines (57 loc) · 1.36 KB
/
Longs.java
File metadata and controls
66 lines (57 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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<Long, F<Long, Long>> add = longAdditionSemigroup.sum();
/**
* Curried Long multiplication.
*/
public static final F<Long, F<Long, Long>> multiply = longMultiplicationSemigroup.sum();
/**
* Curried Long subtraction.
*/
public static final F<Long, F<Long, Long>> subtract = curry(new F2<Long, Long, Long>() {
public Long f(final Long x, final Long y) {
return x - y;
}
});
/**
* Negation.
*/
public static final F<Long, Long> negate = new F<Long, Long>() {
public Long f(final Long x) {
return x * -1L;
}
};
/**
* Absolute value.
*/
public static final F<Long, Long> abs = new F<Long, Long>() {
public Long f(final Long x) {
return abs(x);
}
};
/**
* Remainder.
*/
public static final F<Long, F<Long, Long>> remainder = curry(new F2<Long, Long, Long>() {
public Long f(final Long a, final Long b) {
return a % b;
}
});
}