On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres <carlos.torr...@upr.edu> wrote: > (defn count-zeros > "Returns the numbers of zero in a simple sequence of numbers" > [list1] > (cond > (empty? list1) 0 > (not (zero? (first list1))) 0 > :else > (recur (+ 1 (count-zeros (rest list1))))))
Michael's solution works too, but the problem here is that you're calling recur in a way that doesn't make sense. You'd want to replace the call to count-zeros with recur rather than calling both, but it's not in the tail-position, so it can't be TCO'd. Just remove the call to recur and it will work, albeit only for lists small enough to not blow the stack. -Phil -- 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