I have a vector and want to call a function in Clojure. The function accepts many arguments and I have vector.
For example:
(defn f [a b] (+ a b))
and I have the vector:
[1 2]
I can use apply:
(apply f [1 2])
But can I call f
in Clojure like in python?
(f *[1 2]) .
My use case is that I need to dissoc
some keys from a map. I want to call (dissoc amap *keys)
, but it's not supported.
I could use apply
(apply dissoc (cons amap keys))
but it's not so convenient.
What's the best way to do this in Clojure?
apply
? – Andrew Marshall