OnListLoop returns a list and then successive smaller chunks of the list. The execution ends once the list is exhausted.
Onlistloop has one default input and one optional input :
|
The default value of "by" is a cdr. This means that, at each loop, the cdr of the list is returned.
This default value can be replaced by any other Lisp function meant to return a small chunk of list, just as listloop .
Here, onlistloop successively returns smaller chunks of the list, by taking away the first element of the list : it returns cdrs. The result of each loop is collected by collect and returned by the second input of finally. |
The value of "by" is switched to cddr. Onlistloop successively returns cdrs of cdrs : at each step, the two first elements of the list are left aside.
Note that the first input of finally always returns "nil" at the end of the loop.