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
51 lines (40 loc) · 1.03 KB
/
Longs.java
File metadata and controls
51 lines (40 loc) · 1.03 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
package fj.function;
import fj.F;
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((x, y) -> x - y);
/**
* Negation.
*/
public static final F<Long, Long> negate = x -> x * -1L;
/**
* Absolute value.
*/
public static final F<Long, Long> abs = Math::abs;
/**
* Remainder.
*/
public static final F<Long, F<Long, Long>> remainder = curry((a, b) -> a % b);
}