Difference between revisions of "Module:Range/doc"

From blackwiki
Jump to navigation Jump to search
blackwiki>קיפודנחש
(negative and e-notation.)
blackwiki>קיפודנחש
Line 4: Line 4:
  
 
  <nowiki>{{#invoke|Range|inrange
 
  <nowiki>{{#invoke|Range|inrange
| 12
+
| value = 12
 
| 1 2 3..7 50..70 = one, two, three to seven, or fifty to seventy
 
| 1 2 3..7 50..70 = one, two, three to seven, or fifty to seventy
 
| 9..40 = between nine and fourty  
 
| 9..40 = between nine and fourty  
Line 12: Line 12:
  
 
syntax:
 
syntax:
<nowiki>{{#invoke:Range | iswitch | <Number> | (<Range> = Value | )... [default=Value] }}</nowiki>
+
<nowiki>{{#invoke:Range | iswitch | value = <Number> | ( <Range> = Result | )... [default=Result] }}</nowiki>
  
 
:<Number> ::= [-][digits][.][digits][e digits]
 
:<Number> ::= [-][digits][.][digits][e digits]
 
:<Range> ::= [<Number> | <Number>..<Number>]...
 
:<Range> ::= [<Number> | <Number>..<Number>]...
:Value ::= any string that does not contain | or }}
+
:Result ::= any string (can be multiline) that does not contain | or }} (if needed, use {{t|!}}, and {{t|))}}. )
  
if the first parameter matches a ranges, function will return the values of one of the matching ranges. If more than one range matches, it is unpredictable which of the values will be returned.
+
if '''value''' matches a ranges, the function will return the "Result" of one of the matching ranges. If more than one range matches, it is unpredictable which of the results will be returned. The function does not test for overlap.
  
 
if none of the ranges match, and there is a "default", this value will return. otherwise, the function will return an empty string.
 
if none of the ranges match, and there is a "default", this value will return. otherwise, the function will return an empty string.

Revision as of 18:48, 15 March 2013

returns one function called "iswitch", which takes its inspiration from {{#switch, but is limited to numeric values, and allows for ranges.

usage:

{{#invoke|Range|inrange
| value = 12
| 1 2 3..7 50..70 = one, two, three to seven, or fifty to seventy
| 9..40 = between nine and fourty 
| -2e9..0.75 = between minus two billion and three quuarters
| default = None of the ranges matches 12
}}

syntax: {{#invoke:Range | iswitch | value = <Number> | ( <Range> = Result | )... [default=Result] }}

<Number> ::= [-][digits][.][digits][e digits]
<Range> ::= [<Number> | <Number>..<Number>]...
Result ::= any string (can be multiline) that does not contain | or }} (if needed, use Template:T, and Template:T. )

if value matches a ranges, the function will return the "Result" of one of the matching ranges. If more than one range matches, it is unpredictable which of the results will be returned. The function does not test for overlap.

if none of the ranges match, and there is a "default", this value will return. otherwise, the function will return an empty string.