On Sat, Feb 14, 2009 at 11:32 PM, GS <gsincl...@gmail.com> wrote: > > On Feb 14, 12:21 pm, Chouser <chou...@gmail.com> wrote: >> >> (defn count-instances [obj lsts] >> (let [instances-in (fn thisfn [lst] >> (if (seq lst) >> (+ (if (= (first lst) obj) 1 0) >> (thisfn (rest lst))) >> 0))] >> (map instances-in lsts))) > > Notwithstanding your more idiomatic implementation (snipped), wouldn't > "recur" be better than "thisfn"? > > (defn count-instances [obj lsts] > (let [instances-in (fn [lst] > (if (seq lst) > (+ (if (= (first lst) obj) 1 0) > (recur (rest lst))) > 0))] > (map instances-in lsts)))
Yes, you're absolutely right. --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---