diff --git a/documentation/doc.html b/documentation/doc.html index 5fc52c8..c66b3a2 100644 --- a/documentation/doc.html +++ b/documentation/doc.html @@ -73,7 +73,7 @@ ;; => ((1 . 0) (2 . 0) (2 . 1) (3 . 0))
Both accumulating clauses and :for clauses have something called loop variables. In the case of (:for elt (in-list lst))
the loop variable would be the current pair where elt
is the car. Some :acc- or :for-clauses may expose their loop variables so that they can be queried or even updated.
In the case of the menioned in-list
we can choose to expose the current pair, as in the following example:
In the case of the menioned in-list
we can choo se to expose the name of the current pair, as in the following example:
(define (interpose lst between) (loop lp ((:for elt pair (in-list lst))) @@ -85,6 +85,7 @@ (interpose '(1 2 3 4) ':) ; => (1 : 2 : 3 : 4)
In the above example we chose to bind the loop variable of in-list
to pair
. Using pair
we can then query if the next iteration is the empty list and decide not to interpose any value.
Some loop clauses have the option of exposing their loop variable(s). The option to do so is documented under the documentation for each clause.
The pure loop
macro is quite a big hammer for most tasks. Often we want to do simple things, like collect elements into a list or a vector, which means the extra housekeeping of separating accumulators and for clauses are too much heavy lifting. goof-loop provides several simpler forms that can be used in those cases. In these simpler forms :acc is disallowed, and everything not identified as anything else is assumed to be a :for clause. The loop below accumulates the 100 first fibonacci numbers into a list.
(loop/list ((count (up-from 0 (to 100))) @@ -265,4 +266,22 @@ In case of subloops, those are placed instead of <loop-body>. They use the same final-function, and instead of quitting when any <check> triggers they go out to the outer loop. -