3 ms·
I think you're forgetting that the function can have more than one recursive call site within its body. A for-loop is identical to a recursive function contain
by neutronicus 16y ago
I think you're forgetting that the function can have more than one recursive call site within its body. A for-loop is identical to a recursive function containing only one call site within its body.
By contrast, in order to calculate the number of nodes in a binary tree, you would do
(nodes (tree)
(if (tree? tree)
(1+ (nodes (left-node tree))
(nodes (right-node tree)))
0))
which is not like a simple for loop at all.