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 <straszheimjeff...@gmail.com>
wrote:
> Would memfn not work for you?
>
> http://clojure.org/java_interop
>
> On Thu, Feb 5, 2009 at 7:24 PM, kyle smith <the1physic...@gmail.com> 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]
> >  "Calls the given method on each item in the collection."
> >  `(map (fn [x#] (. x# ~@(if args
> >                         (concat (list method) args)
> >                         (list method)))) ~coll))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to