mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 10:49:43 +00:00
59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
created: 20171221184734665
|
|
modified: 20171229211834620
|
|
tags: [[Filter Operators]] [[Negatable Operators]]
|
|
title: range Operator
|
|
type: text/vnd.tiddlywiki
|
|
caption: range
|
|
op-purpose: generate a range of numbers
|
|
op-input: ignored
|
|
op-parameter: a range specification, like `[1,5]`
|
|
op-parameter-name: N
|
|
op-output: a series of evenly spaced numbers ranging from `<begin>` to `<end>`
|
|
|
|
\define range_example(range)
|
|
```
|
|
[range[$range$]]
|
|
```
|
|
|
|
<$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]].
|
|
|
|
|!Purpose|produce a range of numbers|
|
|
|!Input|ignored.|
|
|
|!Parameter|1-3 numbers separated by `,` or `;`.|
|
|
|!Output|A range of numbers starting with |
|
|
|!`!` Output|As ''Output'', but with order reversed.|
|
|
|
|
The parameter has three forms:
|
|
|
|
* `<end>`
|
|
* `<begin>,<end>`
|
|
* `<begin>,<end>,<step>`
|
|
|
|
Each part must be a number, and works as follows:
|
|
|
|
* `<begin>`: start counting at this number. Defaults to 0.
|
|
* `<end>`: stop counting at this number.
|
|
** It will be included 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.
|
|
|
|
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_example "7">>
|
|
|
|
<<range_example "1, 10">>
|
|
|
|
<<range_example "17,13">>
|
|
|
|
<<range_example "1.001, 5, 1">>
|
|
|
|
<<range_example ".5,1.4,.004">> |