diff --git a/documentation/doc.html b/documentation/doc.html index c66b3a2..4d2b328 100644 --- a/documentation/doc.html +++ b/documentation/doc.html @@ -29,6 +29,8 @@ loop-clause = (:for id id* ... seq-expr) | (:acc id id* ... seq-expr) + | (:let id expr) + | (:let* id expr) | (:when guard-expr) | (:unless guard-expr) | (:break break-expr) @@ -103,13 +105,17 @@
(loop/and (clauses ...) body ...)
If all evaluated bodies return truthy, return the result of the last evaluated body. If any body returns #f, stop iteration and return #f. If no body is evaluated, #t is returned.
(loop/or (clauses ...) body ...)
If any evaluated body returns truthy, stop iteration and return the result of that body. If no body returns truthy, return #f. If no body is evaluated, return #f.
(loop/list/parallel (clauses ...) body ...)
Like loop/list, but evaluates each body in parallel.
-(:for binding (in start [update [stop]]))
Binds a loop variable to binding
. It’s first value is start
. It is updated by the update
expression, or is left unchanged if no such expression is present. If a stop
expression is provided, it will be evaluated before each loop body. If the stop
expression returns true, the iteration will be considered exhausted.
A :for clause specifies a number of identifiers that are bound to a value from a sequence. (:for i (up-from 0 10)))
will bind a to all integers between 0 and 10 (excluseve) in order. The first time the loop is executed, it is bound to 0, then 1, then 2, and so on. Some loops has support for exposing their loop variables to the user. In the case of (:for elt pair (in-list lst))
, elt
will be bound to the car of pair
, whereas pair
will be bound to the loop variable used by in-list
to hold the current position of the list.
(:for binding (in start [update [stop]]))
Binds a loop variable to binding
. It’s first value is start
. It is updated by the update
expression, or is left unchanged if no such expression is present. If a stop
expression is provided, it will be evaluated before each loop body. If the stop
expression returns true, the iteration will be considered exhausted.
(loop ((:for a (in 0 b)) (:for b (in 1 (+ a b) (> b 20)))) (display b) (newline))
Will print all fibonacci numbers below 20.
-(:for binding (up-from start [(to bound)] [(by step)]))
(:for binding (up-from start [bound [by]]))
Binds binding
to the number start
up to bound
(exclusive!) by step
. If no bound
is given, it will yield values indefinitely. The second shorter form will not allow unbounded iteration if a step
other than 1
is wanted.
binding
is a loop variable and can thus be changed using named updates.
(:for binding (up-from start [(:to bound)] [(:by step)]))
(:for binding (up-from start [bound [by]]))
Binds binding
to the number start
up to bound
(exclusive!) by step
. If no bound
is given, it will yield values indefinitely. The second shorter form will not allow unbounded iteration if a step
other than 1
is wanted.
binding
is a loop variable and can thus be changed using named updates.
(:for binding (down-from start [(to bound)] [(by step)])
(:for binding (down-from start [bound [by]]))
Binds binding
to the number (- start 1)
down to bound
(inclusive!) by step
. If no bound
is given, it will yield values indefinitely. The second shorter form will not allow unbounded iteration if a step
other than 1
is wanted.
binding
is a loop variable and can thus be changed using named updates.
(:for binding [pair] (in-list expr [by])
Binds binding
to the car of the loop variable pair
. pair
is advanced by applying the procedure by
to it (defaulting to cdr
). The iteration stops when pair
is the empty list.
(:for binding [pairs] (in-lists expr [by])
Works the same as in-list
, but expr
must evaluate to a list of lists. binding
is bound to the car of those lists, and they are advanced by by
, defaulting to cdr
.
(:for binding [index] (in-vector expr [low [high]]))
Binds binding
to all elements in the vector produced by expr
in order from low
to high
. low
defaults to 0 and high
defaults to the last index of the vector.