/wires_functional.clj Secret
Created
November 12, 2013 22:56
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment