Question

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.

Was it helpful?

Solution

Easiest is just to write an anonymous function:

(defn everything [extra]
  (comp #(conj % {:data extra}) another-func))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top