It's because the #() syntax always calls the content as a function. So #(...) is the same as (fn [] (...)). In your case, #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) is the same as: (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})) Note the extra () around {}. In other words, your map is called as a function.
Maps can normally be called as functions, like this: ({:hello :world} :hello) => :world That's why you get the "Wrong number of args" error (and not a "a map is not a function" error). Hope that makes sense. Btw, hyphen is normally used instead of underscore in both variables and keywords. Just a slight style "issue", but maybe you had your reasons. :) Jonathan On Thu, Mar 28, 2013 at 10:16 PM, Ryan <arekand...@gmail.com> wrote: > Hello! > > I am having a small issue with a hash-map initialization and I am failing > to understand why. I have the following situation: > > (def a-list '({:BAR_KEY bar-value}, {:BAR_KEY another-value})) > > > (defn my-function [foo-id a-keyword a-list] > > (map #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) a-list)) >> > > So, by running the above function like this: > > (my-function 5 "my_keyword" a-list) > > > I get the following error: > > *clojure.lang.ArityException: Wrong number of args (0) passed to: >> PersistentArrayMap* > > > I am trying to get the following result: > > ({:foo_id 5 :my_keyword bar-value}, {:foo_id 5 :my_keyword another-value}) > > Any ideas? I have played around in repl for the last 2 hrs but I haven't > found the proper way to do this. > > Thank you for your time :) > > -- > -- > 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 > Note that posts from new members are moderated - please be patient with > your first post. > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.