Consider the following function as an example:
(defn f [x y] (+ x y))
I want to use this function to add 2 to each element of a vector:
[1 2 6 3 6]
I can use the card:
(map f [1 2 6 3 6] [2 2 2 2 2])
But it seems a little ugly to create a second vector where each element is exactly the same.
So I thought using closure was a better approach:
(map (fn g [x] (f x 2)) [1 2 6 3 6])
So my question is:
In clojure, what is the best way to use a map when some arguments don't change?
source
share