I am trying to learn clojure by learning the programing by example
open wiki book. For an excercise demonstrating iteration they give
the following example:
(defn factorial
([n]
(factorial n 1))
([n acc]
(if (= n 0) acc
(recur (dec n) (* acc n)))))
first I don't understand how acc ever gets an initial value?
also the arguments to the function are a list and not a vector?
why is the vector [n acc] on a line by itself?
This function is very confusing to me!! thanks for any help!!
--
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