diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-10-05 06:42:22 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-10-06 12:24:27 -0700 |
commit | 2d76229afdcdf356da469b6a81149553c1fd4952 (patch) | |
tree | 6e74d4748e6c05b9b1fb752f53855e3bf29f84c1 /txr.1 | |
parent | 7f7379793f4732b09350798c22d9ed22dd2f11ba (diff) | |
download | txr-2d76229afdcdf356da469b6a81149553c1fd4952.tar.gz txr-2d76229afdcdf356da469b6a81149553c1fd4952.tar.bz2 txr-2d76229afdcdf356da469b6a81149553c1fd4952.zip |
New function: ginterate.
* eval.c (ginterate_func): New static function.
(ginterate): New function.
(eval_init): Registered ginterate as intrinsic.
* txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -15728,10 +15728,11 @@ argument is accessed. By that time, the variable is initialized and holds the lazy cons itself, which creates the circular reference, and a circular list. -.coNP Functions @ generate and @ giterate +.coNP Functions @ generate @, giterate and @ ginterate .synb .mets (generate < while-fun << gen-fun ) .mets (giterate < while-fun < gen-fun <> [ value ]) +.mets (ginterate < while-fun < gen-fun <> [ value ]) .syne .desc The @@ -15815,10 +15816,25 @@ like this: (lambda () (prog1 v (set v [g v]))))) .cble +The +.code ginterate +function is a variant of +.code giterate +which includes the test-failing item in the generated sequence. +That is to say +.code ginterate +generates the next value and adds it to the lazy list. +The value is then tested using +.metn while-fun . +If that function returns +.codn nil , +then the list is terminated, and no more items are produced. + .TP* Example: .cblk (giterate (op > 5) (op + 1) 0) -> (0 1 2 3 4) + (ginterate (op > 5) (op + 1) 0) -> (0 1 2 3 4 5) .cble .coNP Function @ repeat |