why not change > < type compare functions do a compare on strings as
well?
(defn >
([x] true)
([x y](if (string? x)
(. clojure.lang.Numbers (isPos (.compareTo x y)))
(. clojure.lang.Numbers (gt x y))))
([x y & more]
(if (> x y)
(if (next more)
(recur y (first more) (next more))
(> y (first more)))
false)))
(defn <
([x] true)
([x y](if (string? x)
(. clojure.lang.Numbers (isNeg (.compareTo x y)))
(. clojure.lang.Numbers (gt x y))))
([x y & more]
(if (< x y)
(if (next more)
(recur y (first more) (next more))
(< y (first more)))
false)))
It's just cleaner so we can do things like:
user=> (< "2010-06-11" "2010-11-01")
true
user=> (< "Banana" "Apple")
false
make sense?
Notes:
* I ran a bunch of benchmarks, showing no real impact on performance.
* probably would need to include >= and <= too.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en