我有一个功能,这需要一个序列的功能和一系列参数。 这应该回一矢量的结果的每个功能应用到的顺序的论点。
((solution + max min) 2 3 5 1 6 4) ;;--> [21 6 1]
我试图要解决它与减少但我不知道如何应用的所有功能,它仅适用于第一个功能:
(defn solution
[& args]
(fn [& args2]
(reduce (first args) [] args2)))
我有一个功能,这需要一个序列的功能和一系列参数。 这应该回一矢量的结果的每个功能应用到的顺序的论点。
((solution + max min) 2 3 5 1 6 4) ;;--> [21 6 1]
我试图要解决它与减少但我不知道如何应用的所有功能,它仅适用于第一个功能:
(defn solution
[& args]
(fn [& args2]
(reduce (first args) [] args2)))
使用 juxt
:
((juxt + max min) 2 3 5 1 6 4)
=> [21 6 1]
或定义功能 solution
:
(defn solution
[& args]
(fn [& args2]
(apply (apply juxt args) args2)))
((solution + max min) 2 3 5 1 6 4)
=> [21 6 1]
(def solution juxt)
会做定义solution
.