Difference between revisions of "Template:LSL Function/negative index"
Jump to navigation
Jump to search
m |
m |
||
Line 28: | Line 28: | ||
{{!}}- | {{!}}- | ||
{{!}} First | {{!}} First | ||
{{!}} 0 | {{!}} <code>0</code> | ||
{{!}} -length | {{!}} <code>-{{{length|length}}}</code> | ||
{{!}}- | {{!}}- | ||
{{!}} Last | {{!}} Last | ||
{{!}} length - 1 | {{!}} <code>{{{length|length}}} - 1</code> | ||
{{!}} -1 | {{!}} <code>-1</code> | ||
{{!}}} | {{!}}} | ||
=== Indexes === | === Indexes === | ||
<div style="display:table;"><div style="display:block;"> | <div style="display:table;"><div style="display:block;"> | ||
*Positive indexes count from the beginning, the first item being indexed as | *Positive indexes count from the beginning, the first item being indexed as <code>0</code>, the last as <code>({{{length|length}}} - 1)</code>. | ||
</div></div> | </div></div> | ||
<div style="display:table;"><div style="display:block;"> | <div style="display:table;"><div style="display:block;"> | ||
*Negative indexes count from the far end, the first item being indexed as | *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> | ||
}} | }} |
Revision as of 07:22, 13 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 |