↧
Answer by noisesmith for clojure - refactor from atom into immutable
;; for starters, we can pass the counter through each reduce(defn build-tree [node xs] (let [[counter tree] (reduce (fn [[counter tree] x] (reduce (fn [[counter' t] l] (if-not (= (:val l) -1) (let...
View Articleclojure - refactor from atom into immutable
I have a nested reduce function and I amusing an atom named counter to increment a count every time a condition is met(defrecord TreeNode [val left right])(defn build-tree [node xs] (let [counter (atom...
View Article
More Pages to Explore .....