Skip to content

Commit fc9f9bd

Browse files
committed
Added Ord.isLessThanOrEqualTo to Ord
1 parent e5bc0e1 commit fc9f9bd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

core/src/main/java/fj/Ord.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ public boolean isLessThan(final A a1, final A a2) {
9292
return compare(a1, a2) == Ordering.LT;
9393
}
9494

95+
/**
96+
* Returns <code>true</code> if the first given argument is less than or equal to the second given argument,
97+
* <code>false</code> otherwise.
98+
*
99+
* @param a1 An instance to compare for ordering to another.
100+
* @param a2 An instance to compare for ordering to another.
101+
* @return <code>true</code> if the first given argument is less than or equal to the second given argument,
102+
* <code>false</code> otherwise.
103+
*/
104+
public boolean isLessThanOrEqualTo(final A a1, final A a2) {
105+
return isLessThan(a1, a2) || eq(a1, a2);
106+
}
107+
95108
/**
96109
* Returns <code>true</code> if the first given argument is greater than the second given
97110
* argument, <code>false</code> otherwise.

core/src/main/java/fj/data/List.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ List<A> merge(List<A> xs, List<A> ys, final Ord<A> o) {
962962
final A x = xs.head();
963963
final A y = ys.head();
964964

965-
if (o.isLessThan(x, y) || o.eq(x, y)) {
965+
if (o.isLessThanOrEqualTo(x, y)) {
966966
buf.snoc(x);
967967
xs = xs.tail();
968968
} else {

0 commit comments

Comments
 (0)