The loop-for-count function is provided to allow simple iterative looping.
Syntax
(loop-for-count <range-spec> [do] <action>*) <range-spec> ::= <end-index> | (<loop-variable> [<start-index> <end-index>]) <start-index> ::= <integer-expression> <end-index> ::= <integer-expression>
Performs the given actions the number of times specified by <range-spec>. If <start-index> is not given, it is assumed to be one. If <start-index> is less than <end-index>, then the body of the loop is never executed. The integer value of the current iteration can be examined with the loop variable, if specified.The break and return functions can be used to terminate the loop prematurely. The return value of this function is FALSE unless the return function is used to terminate the loop. Variables from an outer scope may be used within the loop, but the loop variable (if specified) masks any outer variables of the same name. Loops can be nested.
Example
CLIPS> (loop-for-count 2 (printout t "Hello world" crlf)) Hello world Hello world FALSE CLIPS> (loop-for-count (?cnt1 2 4) do (loop-for-count (?cnt2 1 3) do (printout t ?cnt1 " " ?cnt2 crlf))) 2 1 2 2 2 3 3 1 3 2 3 3 4 1 4 2 4 3 FALSE CLIPS>