Skip to content

Instantly share code, notes, and snippets.

@Hendekagon
Last active April 16, 2017 11:31
Show Gist options
  • Save Hendekagon/5f86fb9f38b715728e5a9c2394d5d5b7 to your computer and use it in GitHub Desktop.
Save Hendekagon/5f86fb9f38b715728e5a9c2394d5d5b7 to your computer and use it in GitHub Desktop.
Cyclic tag system in Clojure
; t a list of productions, a an initial sequence
; note this halts with a NPE - it should really
; check for (empty? a) and reduced
(defn g [t a]
(reductions
(fn [[g & t] a]
(if (== 1 g) (concat t a) t))
a (cycle t)))
(take 32 (g [[0 1 1] [1 1 1]] [1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment