Pro*_*sch 7 clojure clojurescript
如何访问之类的东西sin,cos或PI在纯Clojure的方法吗?
例如,如果我想编写一个纯库,我不能使用像(.PI Math)(Java)或(.?PI?js/Math)(JS)这样的东西.
小智 6
最简单的方法是使用Cljx:https://github.com/lynaghk/cljx
有了它你可以写如下:
(* 5 #+clj (.PI Math) #+cljs (.?PI?js/Math))
Run Code Online (Sandbox Code Playgroud)
并将此代码正确编译为Clojure和ClojureScript.
据我所知,没有更好的方法来编写一个代码作为Clojure/ClojureScript运行.
有一些计划在Clojure中包含平台检测,但我认为还没有准备好.