Clojure “我怎么能?”;扩大;要作为函数参数的列表?
我怎样才能使这三个代码段工作Clojure “我怎么能?”;扩大;要作为函数参数的列表?,clojure,arguments,Clojure,Arguments,我怎样才能使这三个代码段工作 (defn bar [a b c] (println a b c)) > (bar :a :b :c) :a :b :c (defn foo [a & args] (bar a args)) ;; some magic is needed here. > (foo :a :b :c) MoralException: You're a bad person for trying this. 我找遍了所有地方,想知道怎么做。我尝试了很多类似于(a
(defn bar [a b c] (println a b c))
> (bar :a :b :c)
:a :b :c
(defn foo [a & args] (bar a args)) ;; some magic is needed here.
> (foo :a :b :c)
MoralException: You're a bad person for trying this.
我找遍了所有地方,想知道怎么做。我尝试了很多类似于
(apply bar[a args])
的方法,但这是一个ArityException(这很有意义)。我能做什么?您不需要将参数包装到向量中的apply
(apply bar a args)
中间的参数在
args
前面,谢谢,我想我必须做一些展平之类的事情。