mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-22 07:30:43 +00:00
seqgen inclusive stop
This commit is contained in:
parent
1684975bb8
commit
0f5306da39
6 changed files with 25 additions and 27 deletions
|
|
@ -15,7 +15,7 @@ typedef struct _mapper_seqgen_state_t {
|
|||
} mapper_seqgen_state_t;
|
||||
|
||||
#define DEFAULT_FIELD_NAME "i"
|
||||
#define DEFAULT_START_STRING "0"
|
||||
#define DEFAULT_START_STRING "1"
|
||||
#define DEFAULT_STOP_STRING "100"
|
||||
#define DEFAULT_STEP_STRING "1"
|
||||
|
||||
|
|
@ -84,11 +84,11 @@ static void mapper_seqgen_usage(FILE* o, char* argv0, char* verb) {
|
|||
fprintf(o, "output as specified by the following options:\n");
|
||||
fprintf(o, "-f {name} Field name for counters; default \"%s\".\n", DEFAULT_FIELD_NAME);
|
||||
fprintf(o, "--start {number} Inclusive start value; default \"%s\".\n", DEFAULT_START_STRING);
|
||||
fprintf(o, "--stop {number} Exclusive stop value; default \"%s\".\n", DEFAULT_STOP_STRING);
|
||||
fprintf(o, "--stop {number} Inclusive stop value; default \"%s\".\n", DEFAULT_STOP_STRING);
|
||||
fprintf(o, "--step {number} Step value; default \"%s\".\n", DEFAULT_STEP_STRING);
|
||||
fprintf(o, "Start, stop, and/or step may be floating-point. Output is integer if start,\n");
|
||||
fprintf(o, "stop, and step are all integers. Step may be negative. It may not be zero\n");
|
||||
fprintf(o, "unless start == stop (in which case zero records are emitted).\n");
|
||||
fprintf(o, "unless start == stop.\n");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -124,16 +124,16 @@ static sllv_t* mapper_seqgen_process(lrec_t* pinrec, context_t* pctx, void* pvst
|
|||
|
||||
mapper_seqgen_state_t* pstate = pvstate;
|
||||
|
||||
int continue_cmp = -1;
|
||||
int continue_cmp = 1;
|
||||
mv_t zero = mv_from_int(0);
|
||||
if (mv_i_nn_lt(&pstate->step, &zero)) {
|
||||
continue_cmp = 1;
|
||||
continue_cmp = -1;
|
||||
}
|
||||
|
||||
sllv_t* poutrecs = sllv_alloc();
|
||||
for (
|
||||
mv_t counter = pstate->start;
|
||||
mv_nn_comparator(&counter, &pstate->stop) == continue_cmp;
|
||||
mv_nn_comparator(&counter, &pstate->stop) != continue_cmp;
|
||||
counter = x_xx_plus_func(&counter, &pstate->step)
|
||||
) {
|
||||
lrec_t* poutrec = lrec_unbacked_alloc();
|
||||
|
|
|
|||
12
c/todo.txt
12
c/todo.txt
|
|
@ -6,14 +6,9 @@ BUGFIXES
|
|||
================================================================
|
||||
TOP OF LIST:
|
||||
|
||||
----------------------------------------------------------------
|
||||
JSON formatting:
|
||||
* indent by two more for jvstack
|
||||
? rework comma placement for jvstack?
|
||||
|
||||
----------------------------------------------------------------
|
||||
10MIN:
|
||||
* sql-schema example -- after JSON formatting fix-up
|
||||
* sql-schema example
|
||||
* publish
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
|
@ -24,8 +19,6 @@ SEQGEN:
|
|||
MORE:
|
||||
! make variadic min & max
|
||||
! print/printn zary
|
||||
! UT/mlh/mld func @ filter
|
||||
! UT/mlh/mld -e, and mixed -f and -e, for filter/put
|
||||
|
||||
UDFs/subrs/localvars:
|
||||
* maybe:
|
||||
|
|
@ -33,6 +26,8 @@ UDFs/subrs/localvars:
|
|||
* hygiene:
|
||||
- valgrinds
|
||||
* UT & doc:
|
||||
- UT/mlh/mld func @ filter
|
||||
- UT/mlh/mld -e, and mixed -f and -e, for filter/put
|
||||
- no begin/end/func/subr within subr
|
||||
- no begin/end/func/subr within func
|
||||
- (lhs) func no subr call
|
||||
|
|
@ -46,6 +41,7 @@ UDFs/subrs/localvars:
|
|||
* UT:
|
||||
- distinct locals within if/elseif/.../else
|
||||
- mlr --opprint --from s put -v '$o1 = a; local a=1000+NR; $o2 = a; a=2000+NR; $o3 = a'
|
||||
- seqgen
|
||||
* doc:
|
||||
- kw autodoc mods for func/subr/call/return; also add NR PI E etc. to keyword help.
|
||||
- multiple filter/put -f (new mld section)
|
||||
|
|
|
|||
|
|
@ -1000,12 +1000,12 @@ VERBS
|
|||
Produces a sequence of counters. Discards the input record stream. Produces
|
||||
output as specified by the following options:
|
||||
-f {name} Field name for counters; default "i".
|
||||
--start {number} Inclusive start value; default "0".
|
||||
--stop {number} Exclusive stop value; default "100".
|
||||
--start {number} Inclusive start value; default "1".
|
||||
--stop {number} Inclusive stop value; default "100".
|
||||
--step {number} Step value; default "1".
|
||||
Start, stop, and/or step may be floating-point. Output is integer if start,
|
||||
stop, and step are all integers. Step may be negative. It may not be zero
|
||||
unless start == stop (in which case zero records are emitted).
|
||||
unless start == stop.
|
||||
|
||||
shuffle
|
||||
Usage: mlr shuffle {no options}
|
||||
|
|
|
|||
|
|
@ -853,12 +853,12 @@ VERBS
|
|||
Produces a sequence of counters. Discards the input record stream. Produces
|
||||
output as specified by the following options:
|
||||
-f {name} Field name for counters; default "i".
|
||||
--start {number} Inclusive start value; default "0".
|
||||
--stop {number} Exclusive stop value; default "100".
|
||||
--start {number} Inclusive start value; default "1".
|
||||
--stop {number} Inclusive stop value; default "100".
|
||||
--step {number} Step value; default "1".
|
||||
Start, stop, and/or step may be floating-point. Output is integer if start,
|
||||
stop, and step are all integers. Step may be negative. It may not be zero
|
||||
unless start == stop (in which case zero records are emitted).
|
||||
unless start == stop.
|
||||
|
||||
shuffle
|
||||
Usage: mlr shuffle {no options}
|
||||
|
|
|
|||
|
|
@ -1138,12 +1138,12 @@ Usage: mlr seqgen [options]
|
|||
Produces a sequence of counters. Discards the input record stream. Produces
|
||||
output as specified by the following options:
|
||||
-f {name} Field name for counters; default "i".
|
||||
--start {number} Inclusive start value; default "0".
|
||||
--stop {number} Exclusive stop value; default "100".
|
||||
--start {number} Inclusive start value; default "1".
|
||||
--stop {number} Inclusive stop value; default "100".
|
||||
--step {number} Step value; default "1".
|
||||
Start, stop, and/or step may be floating-point. Output is integer if start,
|
||||
stop, and step are all integers. Step may be negative. It may not be zero
|
||||
unless start == stop (in which case zero records are emitted).
|
||||
unless start == stop.
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
|
|
|
|||
|
|
@ -4674,12 +4674,12 @@ Usage: mlr seqgen [options]
|
|||
Produces a sequence of counters. Discards the input record stream. Produces
|
||||
output as specified by the following options:
|
||||
-f {name} Field name for counters; default "i".
|
||||
--start {number} Inclusive start value; default "0".
|
||||
--stop {number} Exclusive stop value; default "100".
|
||||
--start {number} Inclusive start value; default "1".
|
||||
--stop {number} Inclusive stop value; default "100".
|
||||
--step {number} Step value; default "1".
|
||||
Start, stop, and/or step may be floating-point. Output is integer if start,
|
||||
stop, and step are all integers. Step may be negative. It may not be zero
|
||||
unless start == stop (in which case zero records are emitted).
|
||||
unless start == stop.
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
|
@ -4688,7 +4688,6 @@ unless start == stop (in which case zero records are emitted).
|
|||
<div class="pokipanel">
|
||||
<pre>
|
||||
$ mlr seqgen --stop 10
|
||||
i=0
|
||||
i=1
|
||||
i=2
|
||||
i=3
|
||||
|
|
@ -4698,6 +4697,7 @@ i=6
|
|||
i=7
|
||||
i=8
|
||||
i=9
|
||||
i=10
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
|
@ -4710,6 +4710,7 @@ i=24
|
|||
i=28
|
||||
i=32
|
||||
i=36
|
||||
i=40
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
|
@ -4722,6 +4723,7 @@ i=36
|
|||
i=32
|
||||
i=28
|
||||
i=24
|
||||
i=20
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue