File tree Expand file tree Collapse file tree 4 files changed +25
-1
lines changed
Expand file tree Collapse file tree 4 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 11[ ![ Build Status] ( https://secure.travis-ci.org/flatland/useful.png )] ( http://travis-ci.org/flatland/useful )
22
3+ ![ lein dependency] ( https://clojars.org/org.flatland/useful/latest-version.svg )
4+
35These two repositories are usually identical:
46
57* https://github.com/amalloy/useful
Original file line number Diff line number Diff line change 1- (defproject org.flatland /useful " 0.11.3 "
1+ (defproject org.flatland /useful " 0.11.4 "
22 :description " A collection of generally-useful Clojure utility functions"
33 :license {:name " Eclipse Public License - v 1.0"
44 :url " http://www.eclipse.org/legal/epl-v10.html"
Original file line number Diff line number Diff line change 176176 (partial apply f))
177177
178178(def ap " A shorthand version of applied" applied )
179+
180+ (defn =to
181+ " Produces an equality predicate from a single object. ((=to x) y) is
182+ the same as (= x y), but if the returned function will be called many
183+ times it may be more efficient than repeated calls to =, because =to
184+ can short-circuit many irrelevant code paths based on knowing the type
185+ of x.
186+
187+ Just a wrapper for clojure.lang.Util/equivPred."
188+ [x]
189+ (if (keyword? x) ; ; a case myssteriously not covered in equivPred
190+ (fn [y]
191+ (identical? x y))
192+ (let [p (clojure.lang.Util/equivPred x)]
193+ (fn [y]
194+ (.equiv p x y)))))
Original file line number Diff line number Diff line change 9090 by-square (key-comparator :ascending square)]
9191 (is (= (sort-by square [-9 -5 1 -2 ])
9292 (sort by-square [-9 -5 1 -2 ])))))
93+
94+ (deftest test-=to
95+ (let [objs [1 :x " x" [5 ] nil (Object. ) {:x 1 } '((a b c) d)]]
96+ (doseq [x objs
97+ y objs]
98+ (is (= (= x y) ((=to x) y))))))
You can’t perform that action at this time.
0 commit comments