Permalink
Browse files

Add optional &args to the map-foo functions, like update-in has

  • Loading branch information...
amalloy committed Aug 31, 2011
1 parent eac75bc commit 8d4e273047b06b4a144120c2c6308e146e501e6d
Showing with 7 additions and 7 deletions.
  1. +1 −1 project.clj
  2. +6 −6 src/useful/map.clj
View
@@ -1,4 +1,4 @@
-(defproject useful "0.7.0-alpha3"
+(defproject useful "0.7.0-alpha4"
:description "A collection of generally-useful Clojure utility functions"
:dependencies [[clojure "1.2.0"]
[org.clojure/tools.macro "0.1.1"]]
View
@@ -45,25 +45,25 @@
(defn map-vals
"Create a new map from m by calling function f on each value to get a new value."
- [m f]
+ [m f & args]
(into {}
(for [[k v] m]
- (map-entry k (f v)))))
+ (map-entry k (apply f v args)))))
(defn map-vals-with-keys
"Create a new map from m by calling function f, with two arguments (the key and value)
to get a new value."
- [m f]
+ [m f & args]
(into {}
(for [[k v] m]
- (map-entry k (f k v)))))
+ (map-entry k (apply f k v args)))))
(defn map-keys-and-vals
"Create a new map from m by calling function f on each key & each value to get a new key & value"
- [m f]
+ [m f & args]
(into {}
(for [[k v] m]
- (map-entry (f k) (f v)))))
+ (map-entry (apply f k args) (apply f v args)))))
(defn update
"Update value in map where f is a function that takes the old value and the supplied args and

0 comments on commit 8d4e273

Please sign in to comment.