summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-10-29 19:58:52 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-10-29 19:58:52 -0700
commit78a77b00d40befdacd4f5044f504ed132755609e (patch)
tree1f8b89a8f005d299ddd6d850d9b43f0a0ba16e6f /txr.1
parentd7a93957e27bbfe6eaebc25b9d539f82dd9e4df3 (diff)
downloadtxr-78a77b00d40befdacd4f5044f504ed132755609e.tar.gz
txr-78a77b00d40befdacd4f5044f504ed132755609e.tar.bz2
txr-78a77b00d40befdacd4f5044f504ed132755609e.zip
awk: implement ranges right using functions.
* share/txr/stdlib/awk.tl (sys:awk%--rng, sys:awk%--rng-, sys:awk%rng+, sys:awk%-rng+, sys:awk%--rng+): New functions. (sys:awk-mac-let): Rewritten range expander. The four basic ranges rng, rng-, -rng and -rng- are handled with in-line expansion, because by doing that we avoid unnecessarily evaluating the from-expression. The remaining cases expand to function calls to the new functions, which receive the flag vector, the index position in that vector and the values of the from and to expressions. The behavior change is that that the -- forms now do the right thing: they hide all leading records that satisfy the from-expression, right to the last record of the range if necessary. * tests/015/awk-rng.expected: Updated. * txr.1: Revise semantic description the -- range types, plus minor fixes.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.117
1 files changed, 9 insertions, 8 deletions
diff --git a/txr.1 b/txr.1
index 53b0836b..6eedd5cc 100644
--- a/txr.1
+++ b/txr.1
@@ -47280,17 +47280,20 @@ However, the range expression yields
.code nil
for the entire leading sequence of consecutive records for which
.meta from
-is true. Regardless of this, it yields true for the last record
-for which
+is true. If
+.meta from
+is true of the
.meta to
-is true.
+record which terminates the range,
+.code nil
+is returned for that record also.
.meIP (--rng- < from << to )
This type of range is active under the same conditions as
However, the range expression yields
.code nil
for the entire leading sequence of consecutive records for which
.meta from
-is true, and also yields nil for the last record which trigger the
+is true, and also yields nil for the last record which triggers the
.meta to
condition.
.meIP (rng+ < from << to )
@@ -47326,11 +47329,9 @@ However, the range expression yields
.code nil
for the entire leading sequence of consecutive records for which
.meta from
-is true, and for which
-.meta to
-is false. For the terminating records for which
+is true. This is the case even for those for which the
.meta to
-is true, it yields true.
+expression is true.
.RE
.coNP Macro @ ff