Skip to content

Commit

Permalink
* copy over min/max logic from Clojure
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed Jan 25, 2025
1 parent b7481f7 commit fee443c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2771,14 +2771,22 @@ reduces them without incurring seq initialization"
(defn ^number max
"Returns the greatest of the nums."
([x] x)
([x y] (cljs.core/max x y))
([x y]
(cond
(.isNaN js/Number x) x
(.isNaN js/Number y) y
:else (cljs.core/max x y)))
([x y & more]
(reduce max (cljs.core/max x y) more)))

(defn ^number min
"Returns the least of the nums."
([x] x)
([x y] (cljs.core/min x y))
([x y]
(cond
(.isNaN js/Number x) x
(.isNaN js/Number y) y
:else (cljs.core/min x y)))
([x y & more]
(reduce min (cljs.core/min x y) more)))

Expand Down

0 comments on commit fee443c

Please sign in to comment.