Skip to content

Instantly share code, notes, and snippets.

@fffej
Created June 30, 2009 06:48
Show Gist options
  • Save fffej/138036 to your computer and use it in GitHub Desktop.
Save fffej/138036 to your computer and use it in GitHub Desktop.
(defn run-machine
"Run the virtual machine with the decoded instructions.
Reset the program counter when complete"
[vm ops update-input]
(update-input vm)
(doseq [[op args] ops]
(apply op (list vm args)) ;; dodgy side effect
(swap! (:counter vm) inc))
(swap! (:counter vm) (constantly 0))
(swap! (:firstrun vm) (constantly false))
vm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment