On Thu, Apr 7, 2011 at 9:11 AM, Baishampayan Ghose <b.gh...@gmail.com> wrote: > On Thu, Apr 7, 2011 at 6:34 PM, Chouser <chou...@gmail.com> wrote: >>>> Given a collection of functions >>>> >>>> (def fs [#(* % 10) #(+ % 1)]) >>>> >>>> and some numbers >>>> >>>> (def c [1 2 3]) >>>> >>>> How do I apply all the functions to c so that the results of one >>>> function are passed to the other. In the same way -> works. Thus in >>>> this case the expected result would be: 11 21 31 >>> >>> A typical use-case for map & comp - >>> >>> (map (apply comp (reverse fs)) c) >>> ; => (11 21 31) >> >> Or if you don't want to use reverse: >> >> (map #(reduce (fn [x f] (f x)) % fs) c) >> >> Hm, BG's solution compiles no new classes, while mine generates two. >> More classes is better, right? :-P > > Sir Chouser is right! ;) > > On a more serious note, how do I find out how many classes a form compiles to?
I was just eyeballing it -- one class per function definition (note this is *not* one class per closure instance created). I suppose you should be able to clear out your *compile-path* directory, AOT compile your forms, and count the number of new .class files in *compile-path*. You should have one per fn, #(), or defn, plus one for each defrecord, deftype, definterface, gen-class, proxy, reify, etc., plus a couple per namespace. But I haven't checked that myself in a while. --Chouser http://joyofclojure.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