Created
February 6, 2010 21:24
-
-
Save francoisdevlin/296970 to your computer and use it in GitHub Desktop.
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 ->r | |
"The proposed Rohner arrow" | |
([x] x) | |
([x form] (if (seq? form) | |
(with-meta (replace {'_ x} form) (meta form)) | |
(list form x))) | |
([x form & more] `(->r (->r ~x ~form) ~@more))) | |
(use 'clojure.walk) | |
user=>(macroexpand-all '(->r c (+ _ 32) (* 1.8 _))) | |
(* 1.8 (+ c 32)) | |
user=>(macroexpand-all '(->r c count)) | |
(count c) | |
user=>(macroexpand-all '(->r [] (conj _ 1) (into _ [2 3]) (map inc _) (mapcat #(vector % %) _) (vec _) (conj _ 5 5))) | |
(conj (vec (mapcat (fn* [p1__3706] (vector p1__3706 p1__3706)) (map inc (into (conj [] 1) [2 3])))) 5 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment