Hacker News new | ask | show | jobs
by blossoms 4589 days ago
http://clojurescriptkoans.com/#higher-order-functions/10 got me good. Why is it one needs to use `(count a) (count b)` instead of just `a b` like worked when comparing string lengths in a previous ClojureScript Koan?
1 comments

The `<` function only works on numbers but, unlike java, it will correctly coerce numbers with different representations.

    (< 1 ;; Long
       1.5 ;; Double
       2N ;; BigInt
       )
If you want java-style comparisons use `compare` instead.

EDIT: Ooops, this is cljs, not clojure. The correct answer is that string comparison is lexicographic in js:

    "is" < "length" < "word"