Difference between revisions of "Template:LSL Function/negative index"
Jump to navigation
Jump to search
m |
m |
||
Line 19: | Line 19: | ||
{{{{#var:t}}|{{{2|{{#var:ni_p1}}}}}|{{{3|{{#var:ni_p2}}}}}|{{{4|{{#var:ni_p3}}}}}|noExclude={{{noExclude|}}}}} | {{{{#var:t}}|{{{2|{{#var:ni_p1}}}}}|{{{3|{{#var:ni_p2}}}}}|{{{4|{{#var:ni_p3}}}}}|noExclude={{{noExclude|}}}}} | ||
{{#if:{{{noSpec|}}}|| | |||
{{#vardefine:spec|{{#var:spec}} | {{#vardefine:spec|{{#var:spec}} | ||
{{#if:{{#var:t}}| | {{#if:{{#var:t}}| | ||
Line 42: | Line 43: | ||
*Negative indexes count from the far end, the first item being indexed as <code>-{{{length|length}}}</code>, the last as <code>-1</code>. | *Negative indexes count from the far end, the first item being indexed as <code>-{{{length|length}}}</code>, the last as <code>-1</code>. | ||
</div></div> | </div></div> | ||
}} | |||
}} | }} | ||
}} | }} |
Latest revision as of 16:47, 1 May 2016
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 |