Skip to content

Instantly share code, notes, and snippets.

@luxbock luxbock/if-vs-cond.clj Secret
Last active Aug 29, 2015

Embed
What would you like to do?
(defn branch-off
"Draws the game tree from an initial node and rules of the game."
[rules {:keys [pid id] :as node}]
(cond
(node/terminal? node) node
(nil? pid) (branch-off rules (assoc node :pid -1 :id 0))
:else (assoc node
:actions (map-vals (partial branch-off rules)
(add-ids id (map-actions rules node))))))
;; vs.
(defn branch-off
"Draws the game tree from an initial node and rules of the game."
[rules {:keys [pid id] :as node}]
(if (node/terminal? node)
node
(if (nil? pid)
(branch-off rules (assoc node :pid -1 :id 0))
(assoc node
:actions (map-vals (partial branch-off rules)
(map-actions rules node))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.