Skip to content
Browse files

made reduce code compatible with pre-1.4 clojure. added 1.4 and 1.3

multi test targets
  • Loading branch information...
1 parent d712544 commit 4cb344d5549d227fddc6c1b52628476b78cabb1e @vgeshel committed Apr 23, 2012
Showing with 32 additions and 19 deletions.
  1. +3 −1 project.clj
  2. +29 −18 src/potemkin/map.clj
View
4 project.clj
@@ -3,5 +3,7 @@
:dependencies [[org.clojure/clojure "1.3.0"]]
:repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}
:multi-deps {"1.2" [[org.clojure/clojure "1.2.1"]]
+ "1.3" [[org.clojure/clojure "1.3.0"]]
"1.4a" [[org.clojure/clojure "1.4.0-alpha4"]]
- "1.4s" [[org.clojure/clojure "1.4.0-master-SNAPSHOT"]]})
+ "1.4s" [[org.clojure/clojure "1.4.0-master-SNAPSHOT"]]
+ "1.4" [[org.clojure/clojure "1.4.0"]]})
View
47 src/potemkin/map.clj
@@ -59,8 +59,8 @@
clojure.lang.IPersistentCollection
(equiv [this x]
(and
- (map? x)
- (= x (into {} this))))
+ (map? x)
+ (= x (into {} this))))
(cons [this o]
(if-let [[k v] (seq o)]
(assoc this k v)
@@ -74,27 +74,38 @@
(seq [this]
(map #(MapEntry. % (.valAt this % nil)) (potemkin.protocols/keys* this ~unwrapped-data)))
- clojure.core.protocols.CollReduce
- (coll-reduce
- [this f]
- (reduce f (seq this)))
-
- (coll-reduce
- [this f val#]
- (reduce f val# (seq this)))
+ ~@(when (or (> (:major *clojure-version*) 1)
+ (and (= (:major *clojure-version*) 1)
+ (>= (:minor *clojure-version*) 4)))
+ `(clojure.core.protocols.CollReduce
+ (coll-reduce
+ [this f]
+ (reduce f (seq this)))
+ (coll-reduce
+ [this f val#]
+ (reduce f val# (seq this)))))
+
+ ;; clojure.core.protocols.CollReduce
+ ;; (coll-reduce
+ ;; [this f]
+ ;; (reduce f (seq this)))
+
+ ;; (coll-reduce
+ ;; [this f val#]
+ ;; (reduce f val# (seq this)))
Object
(hashCode [this]
(reduce
- (fn [acc [k v]]
- (unchecked-add acc (bit-xor (hash k) (hash v))))
- 0
- (seq this)))
+ (fn [acc [k v]]
+ (unchecked-add acc (bit-xor (hash k) (hash v))))
+ 0
+ (seq this)))
(equals [this x]
(or (identical? this x)
- (and
- (map? x)
- (= x (into {} this)))))
+ (and
+ (map? x)
+ (= x (into {} this)))))
(toString [this]
(str (into {} this)))
@@ -168,7 +179,7 @@
~@(map
(fn [n]
`(invoke [this ~@(repeat n '_)]
- ~(throw-arity n)))
+ ~(throw-arity n)))
(range 3 21))
(applyTo [this args]

0 comments on commit 4cb344d

Please sign in to comment.
Something went wrong with that request. Please try again.