Skip to content

Instantly share code, notes, and snippets.

@boxxxie
Created August 10, 2011 22:02
Show Gist options
  • Save boxxxie/1138396 to your computer and use it in GitHub Desktop.
Save boxxxie/1138396 to your computer and use it in GitHub Desktop.
(defn contains-transaction? [transactions transaction] (contains? transactions (:TransactionID transaction)))
(defmulti conj-transaction contains-transaction?)
(defmethod conj-transaction true [transactions transaction]
(let[id (:TransactionID transaction)
transaction-list (get transactions id)]
(assoc transactions id (conj transaction-list transaction))))
(defmethod conj-transaction false [transactions transaction]
(let [id (:TransactionID transaction)]
(assoc transactions id (vector transaction))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment