I'm new to clojure as well, so someone please correct me if the following
explanation is wrong, but I'll give it a shot :).
The JVM does not natively support TCO; clojure uses the recur form to
accomplish what is effectively the same thing despite that shortcoming of
its host. The recur form wo
if (n == 0) return the "factorial", else go to the "loop label" and recur
with the two parameters (n--) and (factorial * n). Go on until n-- reaches
0.
In a Java-like translation we could have:
int n = number;
factorial = 1;
while(n > 0){
factorial *= n--;
}
return factorial;
On Sun, Apr
I'm very new to Clojure. And I was pretty much interested to learn
about vectors, list . maps in clojure.
I have a code like this :
(defn factorial-1 [number]
"computes the factorial of a positive integer
in a way that doesn't consume stack space"
(loop [n number factorial 1]
(if (zero