clojure API学习(2) 比较操作
注:本文基于jdk1.6,clojure1.2
比较操作等于=??? clojure中的等于和java中的equals方法类似,但是clojure中的=还能够作用于nil、数字和集合上面。看看例子:
??? 从上面的例子来看,=应该是做的值比较,那我们再来验证一下看看:
user> (source >=)(defn >= "Returns non-nil if nums are in monotonically non-increasing order, otherwise false." {:inline (fn [x y] `(. clojure.lang.Numbers (gte ~x ~y))) :inline-arities #{2} :added "1.0"} ([x] true) ([x y] (. clojure.lang.Numbers (gte x y))) ([x y & more] (if (>= x y) (if (next more) (recur y (first more) (next more)) (>= y (first more))) false)))??
?