Skip to content

Instantly share code, notes, and snippets.

@chr15m
Last active June 28, 2016 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chr15m/78887040d48feaa441c850bc58d600ae to your computer and use it in GitHub Desktop.
Save chr15m/78887040d48feaa441c850bc58d600ae to your computer and use it in GitHub Desktop.
Hy macro to print expression before evaluating it
(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