2010/8/10 David Sletten <da...@bosatsu.net> > > On Aug 10, 2010, at 2:22 AM, Laurent PETIT wrote: > > > >> You could accomplish pretty much the same thing by defining two versions >> with different arities: >> (defn count-zeros >> ([l] (count-zeros l 0)) >> ([l result] >> (cond (empty? l) result >> (zero? (first l)) (recur (rest l) (inc result)) >> :else (recur (rest l) result)))) >> > > Though here, the version with different arities "exposes as API for the > user" the 2-arity version, but it may not make sense for the user of your > function to know about this 2-arity version. I personally prefer the first > approach (with a private helper function via defn-) or the last approach > (with an embedded loop). > > > Hence "pretty much the same thing". :) >
Sure, since the OP is new to clojure, I thought giving this "guideline" could be of help to him, Cheers, -- Laurent > > Have all good days, > David Sletten > > > > > -- > 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<clojure%2bunsubscr...@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 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