Clever!

Help me understand why this isn't written

(defn factorial [n]
  (apply * (range 1 (+ n 1)))

instead. That is, I don't get the purpose of the for statement.

On Sun, Nov 23, 2008 at 4:08 PM, prhlava <[EMAIL PROTECTED]> wrote:
>
>
> Hello folks,
>
> While learning, it occured to me that factorial function can be
> written as:
>
>
> (defn factorial [n]
>     (apply * (for [x (range 1 (+ n 1))] x)))
>
>
> I know that it has big argument list for large numbers, but it seems
> to scale nicely (at least in clojure).
>
> I am sure this was discussed to death in lisp groups - have searched
> the net and did not find this version...
>
> kind regards,
>
> Vlad
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to