Good point, and a good reason for a macro.
On Thu, Feb 5, 2009 at 8:50 PM, kyle smith wrote:
>
> Of course those would work, but I got sick of typing them over and
> over.
>
> (map-method length ["mary" "had" "a" "little" "lamb"])
Of course those would work, but I got sick of typing them over and
over.
(map-method length ["mary" "had" "a" "little" "lamb"])
(map-method indexOf ["mary" "had" "a" "little" &qu
1 1)
On Feb 5, 5:05 pm, Jeffrey Straszheim
wrote:
> Would memfn not work for you?
>
> http://clojure.org/java_interop
>
> On Thu, Feb 5, 2009 at 7:24 PM, kyle smith wrote:
>
> > I often need to call a java method on each element in a collection. I
> > didn't fin
Would memfn not work for you?
http://clojure.org/java_interop
On Thu, Feb 5, 2009 at 7:24 PM, kyle smith wrote:
>
> I often need to call a java method on each element in a collection. I
> didn't find anything on the group, so I wrote a macro.
>
> (defmacro map-method
I often need to call a java method on each element in a collection. I
didn't find anything on the group, so I wrote a macro.
(defmacro map-method [method coll & args]
"Calls the given method on each item in the collection."
`(map (fn [x#] (. x# ~@(if args