Write a function which allows you to create function compositions. The parameter list should take a variable number of functions, and create a function applies them from right-to-left.
(fn [& fs]
(fn [& args]
(->> (reverse fs)
(reduce #(apply %2 %1) args))))
http://www.4clojure.com/problem/58
=> (= [3 2 1] ((_ rest reverse) [1 2 3 4]))
clojure.lang.ArityException: Wrong number of args (4) passed to: core$rest
是什么导致了这个错误?我看不到它。
最佳答案
它在您对 apply
的使用中 - 这会将最后一个参数变成一个扁平的参数列表,创建一个看起来像这样的调用:
(休息 1 2 3 4)
这可能不是您想要的......并解释了您遇到的错误。
关于Clojure:传递给 core$rest 的参数 (4) 数量错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15535833/