purpose | generate a range of numbers |
---|---|
input | ignored |
parameter | N =a range specification, like [1],[5] |
output | a series of evenly spaced numbers ranging from [BEGIN] to [END] |
! output | a series of evenly spaced numbers ranging from [BEGIN] to [END] in reverse order |
Learn more about how to use Filters
The range
operator produces a list of numbers counting up or down. It is useful for counting and numbering.
Introduced in v5.2.0 The range operator has been updated to use multiple parameters. Prior to this version, the range operator only had one parameter, with the three parts delimited by ,
, ;
or :
.
In the descriptions below the words BEGIN
, END
and STEP
are placeholders.
[range[END]]
[range[BEGIN],[END]]
[range[BEGIN],[END],[STEP]]
The behaviour depends on the number of parameters:
Parameter(s) Literal | Output |
[END] | Whole numbers up to [END] eg: [range[7]] |
[BEGIN],[END] | Numbers from [BEGIN] to [END] , spaced by whole numbers eg: [range[1],[10]] |
[BEGIN],[END],[STEP] | Numbers from [BEGIN] to [END] spaced out by [STEP] eg: [range[1],[7],[2]] |
Parameter(s) Dynamic | Output |
<END> | Whole numbers up to <END> eg: [range<myRangeEnd>] .The myRangeEnd variable has to be defined somewhere else with eg: $let widget |
{BEGIN},<END> | Numbers from {BEGIN} to <END> eg: [range{myRangeStart},<myRangeEnd>] .The myRangeStart will be transcluded from a tiddler "myRanageStart" and myRangeEnd comes from a variable |
Each parameter must be a number, and works as follows:
[BEGIN]
: start counting at this number.- Defaults to 1 if
[END]
is at least 1 (or -1 if[END]
is at most -1).
- Defaults to 1 if
[END]
: stop counting at this number.- This number will appear in the list unless it falls between two steps.
[STEP]
: count up (or down) by this amount.- Defaults to 1.
- Cannot be zero.
- We always count from
[BEGIN]
toward[END]
, whether[STEP]
is positive or negative.
The number of decimal points in the output is fixed, and based on the parameter with the most decimal points.
To prevent the browser from freezing, range
is currently limited to 10,000 values.
Examples
<$list variable=n filter="[range[7]]" join=", "><<n>></$list>
That renders as:
1, 2, 3, 4, 5, 6, 7
<$list variable=n filter="[range[3],[10]]" join=", "><<n>></$list>
That renders as:
3, 4, 5, 6, 7, 8, 9, 10
<$list variable=n filter="[range[17],[13]]" join=", "><<n>></$list>
That renders as:
17, 16, 15, 14, 13
<$list variable=n filter="[range[1.001],[8],[2]]" join=", "><<n>></$list>
That renders as:
1.001, 3.001, 5.001, 7.001
<$list variable=n filter="[range[.9],[1.1],[.004]]" join=", "><<n>></$list>
That renders as:
0.900, 0.904, 0.908, 0.912, 0.916, 0.920, 0.924, 0.928, 0.932, 0.936, 0.940, 0.944, 0.948, 0.952, 0.956, 0.960, 0.964, 0.968, 0.972, 0.976, 0.980, 0.984, 0.988, 0.992, 0.996, 1.000, 1.004, 1.008, 1.012, 1.016, 1.020, 1.024, 1.028, 1.032, 1.036, 1.040, 1.044, 1.048, 1.052, 1.056, 1.060, 1.064, 1.068, 1.072, 1.076, 1.080, 1.084, 1.088, 1.092, 1.096, 1.100