implement ALL NONE removal for some of default cases

This commit is contained in:
nathanmarz 2017-01-08 13:30:14 -05:00
parent fca11410b4
commit 9617aa1931

View file

@ -149,24 +149,27 @@
(let [empty-structure (empty structure)] (let [empty-structure (empty structure)]
(cond (and (list? empty-structure) (not (queue? empty-structure))) (cond (and (list? empty-structure) (not (queue? empty-structure)))
;; this is done to maintain order, otherwise lists get reversed ;; this is done to maintain order, otherwise lists get reversed
;;TODO: need to handle NONE here ;;TODO: need to handle NONE here
(doall (map next-fn structure)) (doall (map next-fn structure))
(map? structure) (map? structure)
;; reduce-kv is much faster than doing r/map through call to (into ...) ;; reduce-kv is much faster than doing r/map through call to (into ...)
(reduce-kv (reduce-kv
(fn [m k v] (fn [m k v]
;;TODO: need to handle NONE here (let [newkv (next-fn [k v])]
(let [[newk newv] (next-fn [k v])] (if (identical? newkv i/NONE)
(assoc m newk newv))) m
(assoc m (nth newkv 0) (nth newkv 1)))))
empty-structure empty-structure
structure) structure)
:else :else
;;TODO: need to handle NONE here (->> structure
(->> structure (r/map next-fn) (into empty-structure)))))) (r/map next-fn)
(r/filter #(-> % (identical? i/NONE) not))
(into empty-structure))))))
#?(:cljs default) #?(:cljs default)