我想要的东西给了我传递给函数的实际值的序列,类似于javascript函数中的参数值.
我知道我可以使用获取整个函数参数列表
(defn fx [& args]
args)
<= (fx {:a 1} 2)
=> ({:a 1} 2)
Run Code Online (Sandbox Code Playgroud)
但这消除了我的功能上的arity.我希望有类似的东西
(defn fx [{:keys [a]} b]
(MAGIC_FUNCTION_THAT_RETURNS_THE_ARGS_VALUES))
<= (fx {:a 1} 2)
=> ({:a 1} 2)
Run Code Online (Sandbox Code Playgroud)
是否有可能获得传递给函数的原始值序列?
不太好,因为它需要将参数作为向量传递,但似乎很合适
user.main=> (defn fx [[{:keys [a] :as e} b :as o]] [a b e o])
#'user.main/fx
user.main=> (fx [{:a 1} 2])
[1 2 {:a 1} [{:a 1} 2]]
user.main=>
Run Code Online (Sandbox Code Playgroud)