Week 2: Circuit Simulation, Functional Wires

Mmm actually I think that write Protocol and Record is not so so "Clojure's Style".
What do you think about this implementation?
(def ^:private actions :actions)
(def ^:private sigVal :sigVal)
(defn wire [s a] {sigVal s, actions a})
(defn- update-with [w k v f] (assoc w k (f w v)))
(defn- launch-actions [w s]
(let [_ (if (not= s (w get-signal)) (doall (map #(%) (w actions))))]
s))
(defn- cons-actions [w a] (cons a (actions w)))
(defn get-signal [wire] (sigVal wire))
(defn set-signal [w s] (update-with w sigVal s launch-actions))
(defn add-action [w a] (update-with w actions a cons-actions))
I'm learning Clojure.. I'm not a Guru so I'm trying to always improve my "Clojure Functional Style".
I'll really appreciate any opinion you have on this!! :D

Comments