Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

multi test targets
  • Loading branch information...
commit 4cb344d5549d227fddc6c1b52628476b78cabb1e 1 parent d712544
Vadim Geshel authored

Showing 2 changed files with 32 additions and 19 deletions. Show diff stats Hide diff stats

  1. +3 1 project.clj
  2. +29 18 src/potemkin/map.clj
4 project.clj
@@ -3,5 +3,7 @@
3 3 :dependencies [[org.clojure/clojure "1.3.0"]]
4 4 :repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}
5 5 :multi-deps {"1.2" [[org.clojure/clojure "1.2.1"]]
  6 + "1.3" [[org.clojure/clojure "1.3.0"]]
6 7 "1.4a" [[org.clojure/clojure "1.4.0-alpha4"]]
7   - "1.4s" [[org.clojure/clojure "1.4.0-master-SNAPSHOT"]]})
  8 + "1.4s" [[org.clojure/clojure "1.4.0-master-SNAPSHOT"]]
  9 + "1.4" [[org.clojure/clojure "1.4.0"]]})
47 src/potemkin/map.clj
@@ -59,8 +59,8 @@
59 59 clojure.lang.IPersistentCollection
60 60 (equiv [this x]
61 61 (and
62   - (map? x)
63   - (= x (into {} this))))
  62 + (map? x)
  63 + (= x (into {} this))))
64 64 (cons [this o]
65 65 (if-let [[k v] (seq o)]
66 66 (assoc this k v)
@@ -74,27 +74,38 @@
74 74 (seq [this]
75 75 (map #(MapEntry. % (.valAt this % nil)) (potemkin.protocols/keys* this ~unwrapped-data)))
76 76
77   - clojure.core.protocols.CollReduce
78   - (coll-reduce
79   - [this f]
80   - (reduce f (seq this)))
81   -
82   - (coll-reduce
83   - [this f val#]
84   - (reduce f val# (seq this)))
  77 + ~@(when (or (> (:major *clojure-version*) 1)
  78 + (and (= (:major *clojure-version*) 1)
  79 + (>= (:minor *clojure-version*) 4)))
  80 + `(clojure.core.protocols.CollReduce
  81 + (coll-reduce
  82 + [this f]
  83 + (reduce f (seq this)))
  84 + (coll-reduce
  85 + [this f val#]
  86 + (reduce f val# (seq this)))))
  87 +
  88 + ;; clojure.core.protocols.CollReduce
  89 + ;; (coll-reduce
  90 + ;; [this f]
  91 + ;; (reduce f (seq this)))
  92 +
  93 + ;; (coll-reduce
  94 + ;; [this f val#]
  95 + ;; (reduce f val# (seq this)))
85 96
86 97 Object
87 98 (hashCode [this]
88 99 (reduce
89   - (fn [acc [k v]]
90   - (unchecked-add acc (bit-xor (hash k) (hash v))))
91   - 0
92   - (seq this)))
  100 + (fn [acc [k v]]
  101 + (unchecked-add acc (bit-xor (hash k) (hash v))))
  102 + 0
  103 + (seq this)))
93 104 (equals [this x]
94 105 (or (identical? this x)
95   - (and
96   - (map? x)
97   - (= x (into {} this)))))
  106 + (and
  107 + (map? x)
  108 + (= x (into {} this)))))
98 109 (toString [this]
99 110 (str (into {} this)))
100 111
@@ -168,7 +179,7 @@
168 179 ~@(map
169 180 (fn [n]
170 181 `(invoke [this ~@(repeat n '_)]
171   - ~(throw-arity n)))
  182 + ~(throw-arity n)))
172 183 (range 3 21))
173 184
174 185 (applyTo [this args]

0 comments on commit 4cb344d

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