Skip to content

Instantly share code, notes, and snippets.

@karansag
Last active August 29, 2015 14:11
Show Gist options
  • Save karansag/2b907d0d9c570552d33f to your computer and use it in GitHub Desktop.
Save karansag/2b907d0d9c570552d33f to your computer and use it in GitHub Desktop.
Naive Infix
(defmacro infix [form]
(let [init (cons (second form) (cons (first form) (drop 2 form)))]
(for [x init] (if (list? x) `(infix ~x) x))))
(infix ('(1 2) conj 0)) ; works as expected, even using lists as operands...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment