Thanks for the clarification! *--* *Eduardo Aquiles Radanovitsck* ThoughtWorks Brasil
On Fri, Jul 31, 2015 at 6:02 PM, Ben Wolfson <wolf...@gmail.com> wrote: > On Fri, Jul 31, 2015 at 1:57 PM, Eduardo Aquiles Affonso Radanovitsck < > eduardoaquiles...@gmail.com> wrote: > >> Not sure if this is expected or not: >> >> (map (fn [v] {:k v}) #{1 2 3}) >> => ({:k 1} {:k 3} {:k 2}) >> (map #({:k %}) #{1 2 3}) >> ArityException Wrong number of args (0) passed to: PersistentArrayMap >> clojure.lang.AFn.throwArity (AFn.java:429) >> > > The same behavior is visible in earlier versions of clojure and has to do > with how the #(...) syntax is parsed. The workaround is #(do {:k %}). > > Basically, whatever occurs between the #( and the ) is spliced into a > list, so if you have just one single expression, it turns into a function > call: > > user=> (defmacro p [k] (println k)) > #'user/p > user=> (p #({:k %})) > (fn* [p1__7143#] ({:k p1__7143#})) ;; <---- attempting to invoke a map > with zero args > nil > user=> (p #(do {:k %})) > (fn* [p1__7144#] (do {:k p1__7144#})) > nil > > -- > Ben Wolfson > "Human kind has used its intelligence to vary the flavour of drinks, which > may be sweet, aromatic, fermented or spirit-based. ... Family and social > life also offer numerous other occasions to consume drinks for pleasure." > [Larousse, "Drink" entry] > > -- > 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/d/optout. > -- 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/d/optout.