Skip to content

Instantly share code, notes, and snippets.

@jboverfelt
Created October 18, 2014 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jboverfelt/fbaaf5666fe16c291c17 to your computer and use it in GitHub Desktop.
Save jboverfelt/fbaaf5666fe16c291c17 to your computer and use it in GitHub Desktop.
Example of syntax transformation. This is a simple macro but demonstrates the flexibility of being able to define your own syntax
(defmacro foreach [& body]
(let [parts (partition-by #{'in 'do} body)
[v _ lst _ forms] parts]
`(doseq [~(first v) ~(first lst)] (do ~@forms))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment