diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-04-16 06:28:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-04-16 06:28:11 -0700 |
commit | 906f11fb2104c4f6f9770c0c4d747cf44c13bfe6 (patch) | |
tree | 9a2ec92d6e9968dd68e4058dac3d7341dab35ad6 /txr.1 | |
parent | 56beef8defcb5944be1ee523400b382119dbe8fc (diff) | |
download | txr-906f11fb2104c4f6f9770c0c4d747cf44c13bfe6.tar.gz txr-906f11fb2104c4f6f9770c0c4d747cf44c13bfe6.tar.bz2 txr-906f11fb2104c4f6f9770c0c4d747cf44c13bfe6.zip |
Adding dotimes macro.
* eval.c (me_dotimes): New function.
(eval_init): Registering dotimes macro.
* txr.1: Documented dotimes.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -10370,6 +10370,47 @@ is returned. (format t "frobosity value ~a exceeds 150\en" fv)) .cble +.coNP Macro @ dotimes +.synb +.mets (dotimes >> ( var < count-form <> [ result-form ]) << body-form *) +.syne +.desc +The +.code dotimes +macro implements a simple counting loop. +.meta var +is established as a variable, and initialized to zero. +.meta count-form +is evaluated one time to produce a limiting value, which should be a number. +Then, if the value of +.meta var +is less than the limiting value, the +.metn body-form -s +are evaluated, +.meta var +is incremented by one, and the process repeats with a new comparison +of +.meta var +against the limiting value possibly leading to another evaluation of +the forms. + +If +.meta var +is found to equal or exceed the limiting value, then the loop terminates. + +When the loop terminates, its return value is +.code nil +unless a +.meta result-form +is present, in which case the value of that form specifies the return value. + +.metn body-form -s +as well as +.meta result-form +are evaluated in the scope in which the binding of +.meta var +is visible. + .coNP Operator @ unwind-protect .synb .mets (unwind-protect < protected-form << cleanup-form *) |