Skip to content

Instantly share code, notes, and snippets.

@mavant
Created April 1, 2014 18:18
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 mavant/9919872 to your computer and use it in GitHub Desktop.
Save mavant/9919872 to your computer and use it in GitHub Desktop.
(defmacro s-expr->semantic-whitespace "Convert a list of expressions in Clojure to semantic-whitespace form." ([l] (apply str (interpose " "(macroexpand-1 `(s-expr->semantic-whitespace ~l 1))))) ([l n] (map (fn [x] (if (list? x) (apply str "\n" (apply str (repeat n "\t")) (interpose " "(macroexpand-1 `(s-expr->semantic-whitespace ~x ~(+ n 1)))) ) x)) l)))
(print (macroexpand-1 '(s-expr->semantic-whitespace (defn
tabs->parens [c] (map add-parens (rest
(split-on-newlines
c)) (list-deltas (code->numtabs c)))))))
;=>
;defntabs->parens[c]
; map add-parens
; rest
; split-on-newlines c
; list-deltas
; code->numtabs c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment