문제

I need an implementation of the case macro. The original clojure implementation can't be used since it is kind of using the Java case statement internally.

http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/case

case macro

Usage: (case e & clauses)

I could try to build a macro on my own but it would be all clojure. Maybe there is even a way to use real js functionality.

Has anyone a function or macro for that?

도움이 되었습니까?

해결책

UPDATE: case has since been added to ClojureScript. Though we cannot give the performance guarantees, the benefits for portability are more important.

case involves a guarantee that's not possible in JavaScript - constant time dispatch on literals. Is there any reason the following doesn't work for you?

(condp = x
   ...)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top