aboutsummaryrefslogtreecommitdiff
path: root/is/ordered.go
diff options
context:
space:
mode:
Diffstat (limited to 'is/ordered.go')
-rw-r--r--is/ordered.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/is/ordered.go b/is/ordered.go
new file mode 100644
index 0000000..79fada7
--- /dev/null
+++ b/is/ordered.go
@@ -0,0 +1,34 @@
+// SPDX-FileCopyrightText: 2025 Stefan Majewsky <majewsky@gmx.net>
+// SPDX-License-Identifier: Apache-2.0
+
+package is
+
+import "cmp"
+
+// Above(b)(a) is the same as a > b.
+func Above[T cmp.Ordered](rhs T) func(T) bool {
+ return func(lhs T) bool {
+ return lhs > rhs
+ }
+}
+
+// Below(b)(a) is the same as a < b.
+func Below[T cmp.Ordered](rhs T) func(T) bool {
+ return func(lhs T) bool {
+ return lhs < rhs
+ }
+}
+
+// NotAbove(b)(a) is the same as a <= b.
+func NotAbove[T cmp.Ordered](rhs T) func(T) bool {
+ return func(lhs T) bool {
+ return lhs <= rhs
+ }
+}
+
+// NotBelow(b)(a) is the same as a >= b.
+func NotBelow[T cmp.Ordered](rhs T) func(T) bool {
+ return func(lhs T) bool {
+ return lhs >= rhs
+ }
+}