Re:ClojureScript Koans: Learn ClojureScript from inside your...
by blossoms on Friday November 22, 2013 @04:42PM
(#6783958)
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?
[ Parent
| on HN ]
Re:ClojureScript Koans: Learn ClojureScript from inside your...
by jamii on Saturday November 23, 2013 @07:06AM
(#6785779)
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"