Created
June 5, 2018 11:26
-
-
Save Torvaney/911a4d5b631bbf584b38dcb6cc44aaa9 to your computer and use it in GitHub Desktop.
Infix functions in clojure
This file contains 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 $ | |
([x] x) | |
([f x] `(~f ~x)) | |
([x f & args] `(~f ($ ~x) ($ ~@args)))) | |
;; Examples | |
($ 1 + 5) | |
; 6 | |
($ 1 + 5 + 2) | |
; 8 | |
($ 1 + 5 - 2) | |
; 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment