call function to all items of sequence

Viewed 171

I am trying to generate a nested map in Clojure. The problem is that.

  • Firstly I have a sequence ("first" "second" "third" ...).
  • Secondly I have a function by calling which with each element with sequence I want to receive a map like this {: first (function first)}, {: second (function second)} and ..... .
  • Finally i want to gether all result to a new map {:first {...} :second {...} :third {...}}.

Maybe somebody gives me some an instruction or approaches how to do it.

p.s

So i create a draft of my function (it does not work).

(defn finder [sequence function]
 (for [x [sequence]
      :let [ pair {:x (function x)}
             mappa {} (assoc-in mappa pair)]]
    mappa))
4 Answers
Related