Difference between revisions of "Template:LSL Function/negative index"
Jump to navigation
Jump to search
m |
m |
||
Line 51: | Line 51: | ||
{{#vardefineecho:ni_ps|{{#switch:{{#var:ni_c}} | {{#vardefineecho:ni_ps|{{#switch:{{#var:ni_c}} | ||
|0=This function | |0=This function | ||
|1= | |1={{LSLP|{{{2}}}}} | ||
|2= | |2={{LSLP|{{{2}}}}} & {{LSLP|{{{3}}}}} | ||
|3= | |3={{LSLP|{{{2}}}}}, {{LSLP|{{{3}}}}} & {{LSLP|{{{4}}}}} | ||
}}}} {{#if:{{#var:t}}| support{{#ifexpr:{{#var:ni_c}}>1||s}}| ''do{{#ifexpr:{{#var:ni_c}}>1||es}} not'' support }} {{LSLGC|Negative_Index{{#var:lang}}|negative indexes}}.{{PBR}} | }}}} {{#if:{{#var:t}}| support{{#ifexpr:{{#var:ni_c}}>1||s}}| ''do{{#ifexpr:{{#var:ni_c}}>1||es}} not'' support }} {{LSLGC|Negative_Index{{#var:lang}}|negative indexes}}.{{PBR}} | ||
}} | }} | ||
Line 63: | Line 63: | ||
{{#if:{{{nc|{{#var:ni_nc}}}}}|| | {{#if:{{{nc|{{#var:ni_nc}}}}}|| | ||
* If {{#switch:{{#var:ni_c}} | * If {{#switch:{{#var:ni_c}} | ||
|3=either | |3=either {{LSLP|{{{2}}}}}, {{LSLP|{{{3}}}}} or {{LSLP|{{{4}}}}} are | ||
|2=either | |2=either {{LSLP|{{{2}}}}} or {{LSLP|{{{3}}}}} are | ||
|1= | |1={{LSLP|{{{2}}}}} is}} out of bounds {{#if:{{{oob-return|}}}|this function returns {{{oob-return|}}} and}} the script continues to execute without an error message. | ||
{{#if:{{#var:t}}|{{#ifexpr:{{#var:ni_c}}>1|* | {{#if:{{#var:t}}|{{#ifexpr:{{#var:ni_c}}>1|* {{LSLP|{{{2}}}}} & {{LSLP|{{{3}}}}} will form an [[#exclusion_range|exclusion range]] when {{LSLP|{{{2}}}}} is passed {{LSLP|{{{3}}}}} (Approximately: {{LSLP|{{{2}}}}} > {{LSLP|{{{3}}}}}). }}}} | ||
}}}} | }}}} | ||
Revision as of 10:22, 7 June 2012
Format:
{{LSL Function/negative index|boolean|p1|p2|p3}}
Exclude p1, p2, or p3 if not used.
Debugging
#var | value | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
header_footnote |
{{{2}}} & {{{3}}} support negative indexes. | ||||||||||
spec |
Indexes
| ||||||||||
caveats |
| ||||||||||
notes |
Ranges & IndexesThe easiest way to explain how ranges work is to make all indexes positive. Negative indexes are just a way of counting from the tail end instead of the beginning, all negative indexes have a corresponding equivalent positive index (assuming they are in range). Positive indexes past length (after the last index), or negative indexes past the beginning (before the first index) are valid and the effects are predictable and reliable: the entries are treated as if they were there but were removed just before output.
See negative indexes for more information. | ||||||||||
constants_nb | |||||||||||
also_articles |
| ||||||||||
footer |