compiling snippets of clojure(script) into javascript
问题 Where in the clojurescript library can I access a function to compile snippets of clojure into js? I need this to run in the clojure (not clojurescript) repl: (->js '(fn [x y] (+ x y))) => "function(x,y){return x+y}" 回答1: Snippet compilation from Clojure REPL (require '[cljs.analyzer.api :refer [analyze empty-env]]) (require '[cljs.compiler.api :refer [emit]]) (let [ast (analyze (empty-env) '(defn plus [a b] (+ a b)))] (emit ast)) ;; result "cljs.user.plus = (function cljs$user$plus(a,b){