minor code cleanup

This commit is contained in:
Nathan Marz 2016-04-18 12:18:47 -04:00
parent f048d23cda
commit 0134656d0a
2 changed files with 4 additions and 12 deletions

View file

@ -506,13 +506,9 @@
(defn all-select [structure next-fn]
(into [] (r/mapcat next-fn structure)))
#+cljs
(defn next-fn-mapcat-transformation [next-fn]
(mapcat #(next-fn %1)))
#+cljs
(defn all-select [structure next-fn]
(into [] (next-fn-mapcat-transformation next-fn) structure))
(into [] (mapcat #(next-fn %)) structure))
#+cljs
(defn queue? [coll]
@ -520,7 +516,7 @@
#+clj
(defn queue? [coll]
(= (type coll) (type clojure.lang.PersistentQueue/EMPTY)))
(instance? clojure.lang.PersistentQueue coll))
#+clj
(defn all-transform [structure next-fn]
@ -536,17 +532,13 @@
(->> structure (r/map next-fn) (into empty-structure))
)))
#+cljs
(defn next-fn-map-transformation [next-fn]
(map #(next-fn %1)))
#+cljs
(defn all-transform [structure next-fn]
(let [empty-structure (empty structure)]
(if (and (list? empty-structure) (not (queue? empty-structure)))
;; this is done to maintain order, otherwise lists get reversed
(doall (map next-fn structure))
(into empty-structure (next-fn-map-transformation next-fn) structure)
(into empty-structure (map #(next-fn %)) structure)
)))
(deftype AllStructurePath [])

View file

@ -775,6 +775,6 @@
(= s1 s2)
(= (type s1) (type s2))
(= l1 l2)
(seq? l2) ;; Transformed lists are only guaranteed to impelment ISeq
(seq? l2) ; Transformed lists are only guaranteed to impelment ISeq
(= q1 q2)
(= (type q1) (type q2))))))