summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-05 06:42:22 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-06 12:24:27 -0700
commit2d76229afdcdf356da469b6a81149553c1fd4952 (patch)
tree6e74d4748e6c05b9b1fb752f53855e3bf29f84c1 /txr.1
parent7f7379793f4732b09350798c22d9ed22dd2f11ba (diff)
downloadtxr-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.118
1 files changed, 17 insertions, 1 deletions
diff --git a/txr.1 b/txr.1
index 4f496ec3..58c07039 100644
--- a/txr.1
+++ b/txr.1
@@ -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