What is the shape of `headers`? It looks like headers is a sequence of two-element sequences, in which case `reformat-headers` should be something like this -
(defn reformat-headers [headers] (map (fn [[x y]] (hash-map [x 0] (.toString [y 1]))) headers)) ;; note the destructuring. The problem is, the lambda inside the map is expecting two args but is getting one arg (which is a two element sequence) instead. Hope that helps. ~BG On Sun, Jun 30, 2013 at 6:49 AM, Dave Kincaid <kincaid.d...@gmail.com> wrote: > Here is the whole thing: > > (defn reformat-headers > [headers] > (debug (str "Reformatting " headers)) > (map #(hash-map [%1 0] (.toString [%2 1])) headers)) > > (defn spit-messages > "Write out the messages in the given seq." > [messages dest] > (pprint > (for [[metadata ^bytes payload] messages] > {:header (update-in metadata [:headers] reformat-headers) :payload > (String. payload)}) > dest)) > > > On Saturday, June 29, 2013 8:12:26 PM UTC-5, Baishampayan Ghose wrote: >> >> This should work. What does headers look like? Sometimes the #(...) >> reader form can cause problems. Does using the (fn ...) form help? ~BG >> >> On Sun, Jun 30, 2013 at 5:39 AM, Dave Kincaid <kincai...@gmail.com> wrote: >> > Could someone help me decipher the ArityException I'm getting. It's not >> > making sense to me. First here is the exception: >> > >> > ArityException Wrong number of args (1) passed to: >> > lastN$reformat-headers$fn >> > clojure.lang.AFn.throwArity (AFn.java:437) >> > >> > and here is the function reformat-headers: >> > >> > (defn reformat-headers >> > [headers] >> > (map #(.toString %) headers)) >> > >> > as far as I can tell the exception is saying that 1 argument is the >> > wrong >> > number of arguments for reformat-headers, but as you can clearly see it >> > is a >> > function of one argument. What am I interpreting wrong? >> > >> > Thanks, >> > >> > Dave >> > >> > -- >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "Clojure" group. >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > >> >> >> >> -- >> Baishampayan Ghose >> b.ghose at gmail.com > > -- > -- > 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. > > -- Baishampayan Ghose b.ghose at gmail.com -- -- 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.