Change to natural counting in range[N] operator (#3609)

* Add range operator and documentation

* Use 1-based counting in range[N], update docs
logging-improvements
Evan Balster 2018-12-02 02:39:28 -06:00 zatwierdzone przez Jeremy Ruston
rodzic 0f3912ba95
commit b9df224f99
2 zmienionych plików z 21 dodań i 10 usunięć

Wyświetl plik

@ -34,8 +34,16 @@ exports.range = function(source,operator,options) {
}
switch(parts.length) {
case 1:
beg = 0;
end = parts[0];
if (end >= 1) {
beg = 1;
}
else if (end <= -1) {
beg = -1;
}
else {
return [];
}
inc = 1;
break;
case 2:

Wyświetl plik

@ -18,28 +18,31 @@ op-output: a series of evenly spaced numbers ranging from `<begin>` to `<end>`
<$list variable=n filter="[range[$range$]]"><<n>> </$list>
\end
The `range` operator allows a range of numbers to be enumerated, similar to a `for` loop in other programming languages. It's useful in combination with the [[Formula Plugin]].
The `range` operator produces a list of numbers counting up or down. It's useful for counting and numbering, or in combination with the [[Formula Plugin]].
|!Purpose|produce a range of numbers|
|!Input|ignored.|
|!Parameter|1-3 numbers separated by `,` or `;`.|
|!Output|A range of numbers starting with |
|!Output|A series of evenly spaced numbers ranging from `<begin>` to `<end>`|
|!`!` Output|As ''Output'', but with order reversed.|
The parameter has three forms:
* `<end>`
* `<begin>,<end>`
* `<begin>,<end>,<step>`
|Parameter|Output|h
|`<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 0.
* `<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.
** It will be included unless it falls between two steps.
** This number will appear in the list unless it falls between two steps.
* `<step>`: count up (or down) by this amount.
** It may be negated so it counts in the right direction.
** It cannot be zero.
** 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.