Hello, all —

I've written a nifty filter operator for generating numeric ranges in the 
style of "for" loops.  It's an instant power combo with any math 
functionality.  I'll be including it in the next release of my formulas 
plugin <https://github.com/EvanBalster/TiddlyWikiFormula>, but I wanted to 
make a post here in case anybody searches for something like this 
specifically.

The module is attached (drag the JSON file to your wiki to import it).


Docs:

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 
Formulas <http://localhost:8080/#Formulas>.


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[7]]


0 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 (...)

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/af28fc30-5685-4e4d-a1da-b988fe16495c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: $__plugins_ebalster_formula_filters_range.js.json
Description: application/json

Reply via email to