changeset 82:04d539d26bdc

going to try using zippers
author Robert McIntyre <rlm@mit.edu>
date Fri, 09 Mar 2012 13:24:02 -0600
parents db8e0a563c8e
children 95cb2152d7cd
files clojure/com/aurellem/gb_driver.clj clojure/com/aurellem/title.clj
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb_driver.clj	Fri Mar 09 01:43:25 2012 -0600
     1.2 +++ b/clojure/com/aurellem/gb_driver.clj	Fri Mar 09 13:24:02 2012 -0600
     1.3 @@ -137,12 +137,13 @@
     1.4    ([n] (goto (- @current-frame n))))
     1.5  
     1.6  (defn backup-state
     1.7 -  [frame]
     1.8 +  ([] (backup-state (frame)))
     1.9 +  ([frame]
    1.10    (let [save (save-state)]
    1.11      (swap! history #(assoc % frame save))
    1.12      ;;(store-save-to-disk save)
    1.13      (if (> (count @history) *max-history*)
    1.14 -      (swap! history #(dissoc % (first (first %)))))))
    1.15 +      (swap! history #(dissoc % (first (first %))))))))
    1.16  
    1.17  (defn advance []
    1.18    (if *save-history*
    1.19 @@ -160,9 +161,13 @@
    1.20  (defn play-moves
    1.21    ([start moves]
    1.22       (goto start)
    1.23 -     (dorun (map step moves)))
    1.24 +     (dorun (map step moves))
    1.25 +     (backup-state)
    1.26 +     (frame))
    1.27    ([moves]
    1.28 -     (dorun (map step moves))))
    1.29 +     (dorun (map step moves))
    1.30 +     (backup-state)
    1.31 +     (frame)))
    1.32  
    1.33  (defn play
    1.34    ([] (play Integer/MAX_VALUE))
     2.1 --- a/clojure/com/aurellem/title.clj	Fri Mar 09 01:43:25 2012 -0600
     2.2 +++ b/clojure/com/aurellem/title.clj	Fri Mar 09 13:24:02 2012 -0600
     2.3 @@ -138,3 +138,4 @@
     2.4     [] [] [] [] [] [ :a]])
     2.5  
     2.6  
     2.7 +(require '(clojure [zip :as zip]))
     2.8 \ No newline at end of file