comparison clojure/com/aurellem/gb_funs.clj @ 86:9864032ef3c8

cleaned up code and made it to the end of the title
author Robert McIntyre <rlm@mit.edu>
date Sat, 10 Mar 2012 14:24:10 -0600
parents 3f4fdd270059
children
comparison
equal deleted inserted replaced
85:3f4fdd270059 86:9864032ef3c8
118 (reduce (fn [s _] (step s)) state (range n))) 118 (reduce (fn [s _] (step s)) state (range n)))
119 ([n] 119 ([n]
120 (play @current-state n))) 120 (play @current-state n)))
121 121
122 (defn play-moves 122 (defn play-moves
123 ([state moves] 123 ([moves [prev state]]
124 124 (set-state! state)
125 ([moves] 125 (dorun (map (fn [move] (step @current-state move)) moves))
126 (dorun (map (fn [move] (step @current-state move)) moves)))) 126 [(concat prev moves) @current-state]))
127 127
128 ;;;;;;;;;;; 128 ;;;;;;;;;;;
129 129
130 130
131 ;;;;;;;;;;;;;;; CPU data 131 ;;;;;;;;;;;;;;; CPU data
162 (nth (registers state) 3)) 162 (nth (registers state) 3))
163 163
164 (defn DE [state] 164 (defn DE [state]
165 (nth (registers state) 4)) 165 (nth (registers state) 4))
166 166
167 ;;;;;;;;;;;;;;;
168
169 (defmacro defn-memo
170 [& forms]
171 (let [fun-name (first forms)]
172 `(do
173 (defn ~@forms)
174 (alter-var-root (var ~fun-name) memoize))))
167 175