We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents df7218c + 4a1c0b5 commit e75142aCopy full SHA for e75142a
src/plumbing/map.cljc
@@ -49,10 +49,9 @@
49
[m]
50
(when m
51
((fn flatten-helper [keyseq m]
52
- (when m
53
- (if (map? m)
54
- (mapcat (fn [[k v]] (flatten-helper (conj keyseq k) v)) m)
55
- [[keyseq m]])))
+ (if (map? m)
+ (mapcat (fn [[k v]] (flatten-helper (conj keyseq k) v)) m)
+ [[keyseq m]]))
56
[] m)))
57
58
(defn unflatten
test/plumbing/map_test.cljc
@@ -52,10 +52,10 @@
(is (empty? (map/flatten {})))
(is (= [[[] :foo]] (map/flatten :foo)))
(is (= {[:a] 1
- [:b :c] 2
- [:b :d :e] 3
+ [:b :c] false
+ [:b :d :e] nil
[:b :d :f] 4}
- (into {} (map/flatten {:a 1 :b {:c 2 :d {:e 3 :f 4}}})))))
+ (into {} (map/flatten {:a 1 :b {:c false :d {:e nil :f 4}}})))))
59
60
(deftest unflatten-test
61
(is (= {} (map/unflatten nil)))
0 commit comments