This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

range Operator

21st March 2023 at 1:38pm
purposegenerate a range of numbers
inputignored
parameterN=a range specification, like [1],[5]
outputa series of evenly spaced numbers ranging from <begin> to <end>
! outputa 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 :.

[range[<begin>]]
[range[<begin>],[<end>]]
[range[<begin>],[<end>],[<step>]]

The behaviour depends on the number of parameters:

ParameterOutput
<end>Whole numbers up to <end>
<begin>,<end>Numbers from <begin> to <end>, spaced by whole numbers
<begin>,<end>,<step>Numbers from <begin> to <end> spaced out by <step>

Each part 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).
  • <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

[range[7]]

1 2 3 4 5 6 7

[range[1],[10]]

1 2 3 4 5 6 7 8 9 10

[range[17],[13]]

17 16 15 14 13

[range[1.001],[5],[1]]

1.001 2.001 3.001 4.001

[range[.5],[1.4],[.004]]

0.500 0.504 0.508 0.512 0.516 0.520 0.524 0.528 0.532 0.536 0.540 0.544 0.548 0.552 0.556 0.560 0.564 0.568 0.572 0.576 0.580 0.584 0.588 0.592 0.596 0.600 0.604 0.608 0.612 0.616 0.620 0.624 0.628 0.632 0.636 0.640 0.644 0.648 0.652 0.656 0.660 0.664 0.668 0.672 0.676 0.680 0.684 0.688 0.692 0.696 0.700 0.704 0.708 0.712 0.716 0.720 0.724 0.728 0.732 0.736 0.740 0.744 0.748 0.752 0.756 0.760 0.764 0.768 0.772 0.776 0.780 0.784 0.788 0.792 0.796 0.800 0.804 0.808 0.812 0.816 0.820 0.824 0.828 0.832 0.836 0.840 0.844 0.848 0.852 0.856 0.860 0.864 0.868 0.872 0.876 0.880 0.884 0.888 0.892 0.896 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 1.104 1.108 1.112 1.116 1.120 1.124 1.128 1.132 1.136 1.140 1.144 1.148 1.152 1.156 1.160 1.164 1.168 1.172 1.176 1.180 1.184 1.188 1.192 1.196 1.200 1.204 1.208 1.212 1.216 1.220 1.224 1.228 1.232 1.236 1.240 1.244 1.248 1.252 1.256 1.260 1.264 1.268 1.272 1.276 1.280 1.284 1.288 1.292 1.296 1.300 1.304 1.308 1.312 1.316 1.320 1.324 1.328 1.332 1.336 1.340 1.344 1.348 1.352 1.356 1.360 1.364 1.368 1.372 1.376 1.380 1.384 1.388 1.392 1.396 1.400