Mercurial > vba-clojure
diff clojure/com/aurellem/run/title.clj @ 313:8e63b0bb8ea3
major refactoring; made (walk) more robust
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 02 Apr 2012 10:58:16 -0500 |
parents | c7b002525041 |
children | 9a4d3f801c89 |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/run/title.clj Sat Mar 31 00:41:28 2012 -0500 1.2 +++ b/clojure/com/aurellem/run/title.clj Mon Apr 02 10:58:16 2012 -0500 1.3 @@ -1,34 +1,6 @@ 1.4 (ns com.aurellem.run.title 1.5 (:use (com.aurellem.gb gb-driver vbm))) 1.6 1.7 -(defn first-difference [base alt summary root] 1.8 - (loop [branch-point root 1.9 - actions []] 1.10 - (let [base-branch (step branch-point base) 1.11 - base-val (summary base-branch) 1.12 - alt-branch (step branch-point alt) 1.13 - alt-val (summary alt-branch)] 1.14 - (if (not= base-val alt-val) 1.15 - [(conj actions alt) alt-branch] 1.16 - (recur base-branch (conj actions base)))))) 1.17 - 1.18 -(defn advance 1.19 - ([base alt summary [commands state]] 1.20 - (let [[c s] (first-difference base alt summary state)] 1.21 - [(concat commands c) s])) 1.22 - ([base alt [commands state]] 1.23 - (advance base alt AF [commands state])) 1.24 - ([alt [commands state]] 1.25 - (advance [] alt [commands state]))) 1.26 - 1.27 -(defn scroll-text 1.28 - ([script] 1.29 - (advance [:b] [:a :b] script)) 1.30 - ([n script] 1.31 - (reduce (fn [script _] 1.32 - (scroll-text script)) 1.33 - script 1.34 - (range n)))) 1.35 1.36 (defn start [] [[] (root)]) 1.37