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"])
> (map-method indexOf ["mary" "had" "a" "little" "lamb"] (int \a)
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" "lamb"] (int \a))
I find typing # and % repetitive, so this is just a little syntactic
sugar.
--~--~-~--~~---
Or anonymous function literals?
user=> (map #(.length %) ["mary" "had" "a" "little" "lamb"])
(4 3 1 6 4)
user=> (map #(.indexOf % (int \a)) ["mary" "had" "a" "little" "lamb"])
(1 1 0 -1 1)
On Feb 5, 5:05 pm, Jeffrey Straszheim
wrote:
> Would memfn not work for you?
>
> http://clojure.org/java_
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 [method coll & args]
> "