Created
March 3, 2012 14:03
-
-
Save scottlowe/1966338 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def axial-tree-a {:start [\F] | |
:rules {\F "F[+F]F[-F]F"} | |
:angle 25.7 | |
:constants #{\F \+ \- \[ \]} | |
:cmd-map {\F :forward | |
\+ :left | |
\- :right | |
\[ :push | |
\] :pop}}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn apply-rules [grammar pattern] | |
(apply str | |
(replace (:rules grammar) pattern))) | |
(defn gen-commands [grammar n] | |
(nth | |
(iterate | |
(partial apply-rules grammar) (:start grammar)) | |
n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment