A binding vector supplies the local name and iteration bound for dotimes. Its two elements define the variable available to the body and the number of repetitions. section 3.4.5
For dotimes, the binding vector must satisfy this contract:
- Use exactly two elements: a local binding name followed by n. section 3.4.5
- The local name starts at zero and increments by one on each iteration. section 3.4.5
- A zero or negative n skips the body; dotimes returns nil. section 3.4.5
Printing the iteration index
(dotimes [i 3] (println i)) ;; 0 ;; 1 ;; 2 ;; nil Here, [i 3] binds i to each index from zero through two. The body performs side effects, while the overall expression returns nil. section 3.4.5
