comparison clojure/com/aurellem/fragments.clj @ 76:d7c38ce83421

working on disk-backup for save-states
author Robert McIntyre <rlm@mit.edu>
date Thu, 08 Mar 2012 19:48:54 -0600
parents eb7d4efe0f34
children
comparison
equal deleted inserted replaced
75:eb7d4efe0f34 76:d7c38ce83421
15 (concat (repeat n []) 15 (concat (repeat n [])
16 [[:a]] 16 [[:a]]
17 (repeat (- start-frames n 1) [])) 17 (repeat (- start-frames n 1) []))
18 moves (drop start moves)] 18 moves (drop start moves)]
19 (goto start) 19 (goto start)
20 (dorun (map step moves)) 20 (dorun (map step! moves))
21 (nth (registers) 2))) 21 (nth (registers) 2)))
22
23 22
24 (defn earliest-press 23 (defn earliest-press
25 [start] 24 [start]
26 (print "determining bad program-counter...") 25 (print "determining bad program-counter...")
26 (reset)
27 (dorun (dotimes [_ start-frames] (step)))
27 (let [bad-counter (play-start 0 0)] 28 (let [bad-counter (play-start 0 0)]
28 (println bad-counter) 29 (println bad-counter)
29 (loop [n start] 30 (loop [n start]
30 (print "trying" n "...") 31 (print "trying" n "...")
31 (let [nth-counter (play-start n)] 32 (let [nth-counter (play-start (dec n) n)]
32 (println "got" nth-counter) 33 (println "got" nth-counter)
33 (if (= nth-counter bad-counter) 34 (if (= nth-counter bad-counter)
34 (recur (inc n)) n))))) 35 (recur (inc n)) n)))))
35 36
36 37