Clojure: returning a vector from an anonymous function

I wrote a small anonymous function to be used with a map call. The function returns a vector containing a column name and column value from a SQL result set query.

Here is the function (input is the column name):

(fn [name] [(keyword name) (.getObject resultset name)])

This works fine, however when I tried to use a "simplified" version of the anonymous function, I got an error:

#([(keyword %) (.getObject resultset %)])

java.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentVector

Here is the map call:

(into {} (map (fn [name] [(keyword name) (.getObject resultset name)]) column-names))

Is it possible to use the simplified syntax for this function? If so, how?

Thanks.

21
задан Ralph 7 February 2011 в 12:57
поделиться