Last active
August 29, 2015 14:11
-
-
Save karansag/2b907d0d9c570552d33f to your computer and use it in GitHub Desktop.
Naive Infix
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
(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