Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active January 22, 2017 17:53
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 deque-blog/2c224ac4950c2d8a9d32b44aa649227d to your computer and use it in GitHub Desktop.
Save deque-blog/2c224ac4950c2d8a9d32b44aa649227d to your computer and use it in GitHub Desktop.
(defn print-expr [expr]
(walk/postwalk
(fn algebra [e]
(cond
(cst? e) (str e)
(sym? e) e
(add? e) (str "(+ " (string/join " " (rest e)) ")")
(mul? e) (str "(* " (string/join " " (rest e)) ")")
:else e))
expr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment