Advertisement
Guest User

hoeck

a guest
Feb 8th, 2010
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.31 KB | None | 0 0
  1. (defn map-map [from-map func] (reduce merge (for [[key value] from-map] (hash-map key (func value)))))
  2. (map-map {:a 2 :b 4} #(* 3 %))
  3.  
  4. ;; other possible solutions:
  5. (defn map-map [f m]
  6.   (into (empty m) (map (fn [[k v]] [k (f v)]) m)))
  7.  
  8. (let [m {:a 2 :b 4}]
  9.   (merge-with * m (zipmap (keys m) (repeat 3))))
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement