clojurescript - In clojure, how to map a sequence and create a hash-map -
in clojure
, apply function elements of sequence , return map
results keys elements of sequence , values elements of mapped sequence.
i have written following function function. wondering why such function not part of clojure
. maybe it's not idiomatic?
(defn map-to-object[f lst] (zipmap lst (map f lst))) (map-to-object #(+ 2 %) [1 2 3]) => {1 3, 2 4, 3 5}
your function idiomatic.
for fn part of core, think has useful people. part of core language , not quite debatable. think amount of stringutils classes can find in java.
Comments
Post a Comment