Clojure: returning a vector from an anonymous function -
i wrote small anonymous function used map
call. function returns vector containing column name , column value sql result set query.
here function (input column name):
(fn [name] [(keyword name) (.getobject resultset name)])
this works fine, when tried use "simplified" version of anonymous function, got error:
#([(keyword %) (.getobject resultset %)]) java.lang.illegalargumentexception: wrong number of args (0) passed to: persistentvector
here map
call:
(into {} (map (fn [name] [(keyword name) (.getobject resultset name)]) column-names))
is possible use simplified syntax function? if so, how?
thanks.
your problem simple syntax trying evaluate vector function call.
you can insert "identity" function make work, simple function return vector unchanged:
#(identity [(keyword %) (.getobject resultset %)])
Comments
Post a Comment