Here's the Lisp function to find the length of the list. It is recursive:
(defun recursive-list-length (L) "A recursive implementation of list-length." (if (null L) 0 (1+ (recursive-list-length (rest L)))))
He reads: "the length of the list is 0 if this list is empty, or 1 plus the length of the sub-list, starting from the second element).
And this is strlen implementation - a C function that types the length of a char* string with nul-terminated. This is iterative:
size_t strlen(const char *s) { size_t n; n = 0; while (*s++) n++; return(n); }
The goal is to repeat some operation. Using iteration, you use an explicit loop (for example, while in strlen code). Using recursion, your function calls itself (usually) with a smaller argument, and so on, until the boundary condition is met ( null L in the code above). This also repeats the operation, but without an explicit loop.
source share