On Sat, 19 Jun 2010 20:13:07 -0400 David Nolen <[email protected]> wrote:
> On Sat, Jun 19, 2010 at 4:10 PM, Michał Marczyk > <[email protected]> wrote: > > (defn fact [n] > > (loop [n n r 1] > > (if (zero? n) > > r > > (recur (dec n) (* r n))))) > > Huh? That doesn't look like it's going to work at all. > > 1) 1 is primitive, we know that, accept it > 2) we don't know the type of n, what will (* r n) be? > 3) BOOM! > > My suggestion is to stop it with the contrived examples. Start showing some > real code, real problems in your real programs. Using loop/recur is already > the beginning of code smell for anything that is not performance sensitive. Oh, come on. I didn't write that example, but it's a perfect reasonable implementation of the factorial loop algorithm. I'd say that you're calling "using loop/recur" a code smell is itself a smell, indicating that loop/recur is broken. <mike -- Mike Meyer <[email protected]> http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
