Last active
June 28, 2016 12:24
-
-
Save chr15m/78887040d48feaa441c850bc58d600ae to your computer and use it in GitHub Desktop.
Hy macro to print expression before evaluating it
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
(import [hy.models.expression [HyExpression]]) | |
(defn print-expression [expr] | |
(+ "(" (.join " " (list-comp (if (= (type x) HyExpression) (print-expression x) (str x)) [x expr])) ")")) | |
(defmacro print-eval [expr] | |
(quasiquote (do | |
(print (unquote (print-expression expr))) | |
(unquote expr)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment