1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-17 15:57:12 +00:00

compare functions now work for built ins and 'objects'

This commit is contained in:
Mike Beller
2020-06-04 13:49:09 -04:00
parent 7658ea8335
commit 411c5da6d3
2 changed files with 11 additions and 8 deletions

View File

@@ -692,7 +692,7 @@
fyx (f y x)] (- fyx))
(compare-primitive x y)))
(defn compare-reduce- [op & xs]
(defn compare-reduce- [op xs]
(var r true)
(loop [i :range [0 (- (length xs) 1)]
:let [c (compare (xs i) (xs (+ i 1)))
@@ -705,27 +705,27 @@
(defn compare=
"Equivalent of '=' but using compare function instead of primitive comparator"
[& xs]
(compare-reduce- := xs))
(compare-reduce- = xs))
(defn compare<
"Equivalent of '<' but using compare function instead of primitive comparator"
[& xs]
(compare-reduce- :< xs))
(compare-reduce- < xs))
(defn compare<=
"Equivalent of '<=' but using compare function instead of primitive comparator"
[& xs]
(compare-reduce- :<= xs))
(compare-reduce- <= xs))
(defn compare>
"Equivalent of '>' but using compare function instead of primitive comparator"
[& xs]
(compare-reduce- :> xs))
(compare-reduce- > xs))
(defn compare>=
"Equivalent of '>=' but using compare function instead of primitive comparator"
[& xs]
(compare-reduce- :>= xs))
(compare-reduce- >= xs))
###
###