Skip to content

Instantly share code, notes, and snippets.

@scottlowe
Created March 3, 2012 14:03
Show Gist options
  • Save scottlowe/1966338 to your computer and use it in GitHub Desktop.
Save scottlowe/1966338 to your computer and use it in GitHub Desktop.
(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}})
(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