Chapter 5, Exercise 3 in Clojure for the Brave and True requires:
Implement the assoc-in function. Hint: use the
assocfunction and define its parameters as[m [k & ks] v].
Although I have found this solution (see lines 39-54), I wondered if there was a different way of doing it. When working on the previous exercise, I found this very clear answer by jbm on implementing the comp function to be very helpful.
I've been trying to reduce a partial assoc over a conjoined list of keys and apply the returned function to the final value:
(defn my-part-assoc [m k]
(partial assoc m k))
((reduce my-part-assoc {} [:one :two :three]) "val")
Needless to say, this doesn't work. I am new to Clojure and functional programming and fear my very basic understanding of reduce is leading me down the wrong path. Please can someone provide a more concise answer?