summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clj/clojure/core.clj10
-rw-r--r--src/jvm/clojure/lang/Numbers.java146
2 files changed, 152 insertions, 4 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 3f122846..32a1c55b 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -1033,18 +1033,20 @@
(defn max
"Returns the greatest of the nums."
{:added "1.0"
- :static true}
+ :inline-arities #{2}
+ :inline (fn [x y] `(. clojure.lang.Numbers (max ~x ~y)))}
([x] x)
- ([x y] (if (> x y) x y))
+ ([x y] (. clojure.lang.Numbers (max x y)))
([x y & more]
(reduce1 max (max x y) more)))
(defn min
"Returns the least of the nums."
{:added "1.0"
- :static true}
+ :inline-arities #{2}
+ :inline (fn [x y] `(. clojure.lang.Numbers (min ~x ~y)))}
([x] x)
- ([x y] (if (< x y) x y))
+ ([x y] (. clojure.lang.Numbers (min x y)))
([x y & more]
(reduce1 min (min x y) more)))
diff --git a/src/jvm/clojure/lang/Numbers.java b/src/jvm/clojure/lang/Numbers.java
index a5c151b9..b89ee0e9 100644
--- a/src/jvm/clojure/lang/Numbers.java
+++ b/src/jvm/clojure/lang/Numbers.java
@@ -3797,5 +3797,151 @@ static public boolean equiv(long x, double y){
return x == y;
}
+static public double max(double x, double y){
+ if(x > y){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object max(double x, long y){
+ if(x > y){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object max(double x, Object y){
+ if(x > ((Number)y).doubleValue()){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object max(long x, double y){
+ if(x > y){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+
+static public long max(long x, long y){
+ if(x > y) {
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object max(long x, Object y){
+ if(gt(x,y)){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object max(Object x, long y){
+ if(gt(x,y)){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object max(Object x, double y){
+ if(((Number)x).doubleValue() > y){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object max(Object x, Object y){
+ if(gt(x, y)) {
+ return x;
+ } else {
+ return y;
+ }
+}
+
+
+static public double min(double x, double y){
+ if(x < y){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object min(double x, long y){
+ if(x < y){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object min(double x, Object y){
+ if(x < ((Number)y).doubleValue()){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object min(long x, double y){
+ if(x < y){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+
+static public long min(long x, long y){
+ if(x < y) {
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object min(long x, Object y){
+ if(lt(x,y)){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object min(Object x, long y){
+ if(lt(x,y)){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object min(Object x, double y){
+ if(((Number)x).doubleValue() < y){
+ return x;
+ } else {
+ return y;
+ }
+}
+
+static public Object min(Object x, Object y){
+ if(lt(x,y)) {
+ return x;
+ } else {
+ return y;
+ }
+}
}