Mercurial > vba-clojure
view clojure/com/aurellem/title.clj @ 87:e8855121f413
collect cruft, rename other files
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 10 Mar 2012 14:48:17 -0600 |
parents | 04d539d26bdc |
children | 65c2854c5875 |
line wrap: on
line source
1 (ns com.aurellem.title2 (:use (com.aurellem gb-driver vbm)))4 (defn first-difference [base alt summary root]5 (loop [branch-point root6 actions []]7 (let [base-branch (step branch-point base)8 base-val (summary base-branch)9 alt-branch (step branch-point alt)10 alt-val (summary alt-branch)]11 (if (not= base-val alt-val)12 [(conj actions alt) alt-branch]13 (recur base-branch (conj actions base))))))15 (defn advance16 ([base alt summary [commands state]]17 (let [[c s] (first-difference base alt summary state)]18 [(concat commands c) s]))19 ([base alt [commands state]]20 (advance base alt AF [commands state]))21 ([alt [commands state]]22 (advance [] alt [commands state])))24 (def scroll-text (partial advance [:b] [:a :b]))26 (defn start [] [[] (root)])28 (defn-memo title [start]29 (->> start30 (advance [] [:a])31 (advance [] [:start])32 (advance [] [:a])33 (advance [] [:start])))35 (defn-memo oak [start]36 (->> (title)37 scroll-text38 scroll-text39 scroll-text40 scroll-text41 scroll-text42 scroll-text43 scroll-text44 scroll-text45 scroll-text46 scroll-text47 scroll-text48 scroll-text49 scroll-text50 (advance [] [:a])))52 (defn-memo name-entry []53 (->> (oak)54 (advance [] [:r] DE)55 (play-moves56 [[]57 [:r] [] [:r] [] [:r] [] [:r] []58 [:r] [] [:r] [] [:r] [] [:d] [:a]59 [:l] [] [:l] [] [:l] [] [:l] []60 [:l] [] [:l] [:a] [] [:r] [:a]61 [:r] [] [:r] [] [:r] [] [:r] []62 [:r] [] [:d] [] [:d] [] [:d] [:a]63 ])))65 (defn-memo rival-name-entry []66 (->> (name-entry)67 scroll-text68 scroll-text69 scroll-text70 scroll-text71 scroll-text72 (advance [] [:d])73 (advance [] [:d])74 (advance [] [:a])))76 (defn-memo finish-title []77 (->> (rival-name-entry)78 scroll-text79 scroll-text80 scroll-text81 scroll-text82 scroll-text83 scroll-text84 scroll-text))86 (defn-memo intro []87 (-> (start) title oak name-entry rival-name-entry finish-title))90 ;; TODO might be able to glue these together more elegantly with monads