From b700e8e335f9e6ebf31457262db323273e339afa Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 23 Apr 2022 18:10:56 -0700 Subject: loop: new counting clause. --- cppawk-iter.1 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'cppawk-iter.1') diff --git a/cppawk-iter.1 b/cppawk-iter.1 index d55fb24..490c9cb 100644 --- a/cppawk-iter.1 +++ b/cppawk-iter.1 @@ -84,6 +84,7 @@ iter \- powerful, user-extensible iteration language for Awk \fI// calculating clauses\fP summing (\fIvar\fP, \fIexpr\fP) + counting (\fIvar\fP, \fIexpr\fP) maximizing (\fIvar\fP, \fIexpr\fP) minimizing (\fIvar\fP, \fIexpr\fP) argmax (\fImaxvar\fP, \fIarg\fP, \fIexpr\fP) @@ -787,6 +788,32 @@ ends up with the sum of the samples of the value of .I expr from before each iteration of the loop. +.SS Loop clause \fIcounting\fP +.bk +.B Syntax: + +.ft B + counting (\fIvar\fP, \fIexpr\fP) +.ft R + +.B Description + +The +.B counting +clause initialized +.I var +to zero. Prior to each iteration of the loop, +.I expr +is evaluated and if it yields a true value, then +.I var +is incremented. + +Thus, +.I var +ends up with a count of the number of iterations in which +.I expr +was true. + .SS Loop clauses \fIminimizing\fP and \fImaximizing\fP .bk .B Syntax: -- cgit v1.2.3