Skip to content

Commit 9fca2d5

Browse files
committed
Merge branch '0.11.5'
2 parents 43a4abf + e8646ca commit 9fca2d5

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject org.flatland/useful "0.11.4"
1+
(defproject org.flatland/useful "0.11.5"
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"

src/flatland/useful/fn.clj

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,22 @@
177177

178178
(def ap "A shorthand version of applied" applied)
179179

180-
(defn =to
181-
"Produces an equality predicate from a single object. ((=to x) y) is
180+
(let [impl (delay (try (eval `(fn [x#]
181+
(if (keyword? x) ;; a case myssteriously not covered in equivPred
182+
(fn [y#]
183+
(identical? x# y#))
184+
(let [p# (clojure.lang.Util/equivPred x#)]
185+
(fn [y#]
186+
(.equiv p# x# y#))))))
187+
(catch Exception e ;; running some version prior to equivPred
188+
(fn [x] (fn [y] (= x y))))))]
189+
(defn =to
190+
"Produces an equality predicate from a single object. ((=to x) y) is
182191
the same as (= x y), but if the returned function will be called many
183192
times it may be more efficient than repeated calls to =, because =to
184193
can short-circuit many irrelevant code paths based on knowing the type
185194
of x.
186195
187196
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)))))
197+
[x]
198+
(@impl x)))

0 commit comments

Comments
 (0)