interstar
interstar

Reputation: 27186

How to partial conj?

I'm trying to create a function that applies several processes to a map, including adding / updating some standard items to each map using "conj". I'm doing it by composing several other functions using "comp".

So I tried doing this

(defn everything [extra] (comp (partial conj {:data extra}) another-func) )

Which won't work because conj wants the extra data as the second argument, not the first.

I assume there should be a similarly straightforward way of composing a curried conj, but I can't quite figure out how to do it.

Upvotes: 2

Views: 142

Answers (1)

Charles Duffy
Charles Duffy

Reputation: 295403

Easiest is just to write an anonymous function:

(defn everything [extra]
  (comp #(conj % {:data extra}) another-func))

Upvotes: 3

Related Questions