woodings
woodings

Reputation: 7693

Is there any macro to help make a function with one open argument?

(map (fn [x] (func 1 2 x)) [0 1 2]) where func takes 3 arguments can be written as (map #(func 1 2 %) [0 1 2]) for short. Is it possible to make it even more concise? Like in OCaml, (func 1 2) itself is a function. I don't need to create a new one and pass it to map.

Upvotes: 1

Views: 52

Answers (1)

Joost Diepenmaat
Joost Diepenmaat

Reputation: 17773

Clojure doesn't do auto-currying, so you can't just say (func 1 2), but you can use partial:

(map (partial func 1 2) [0 1 2])

Upvotes: 5

Related Questions