Difference between revisions of "Template:LSL Function/negative index/range"
Jump to navigation
Jump to search
(It doesn't feel like spec anymore, more like notes) |
(I think i've solved my problem without too much information duplication.) |
||
Line 1: | Line 1: | ||
{{#if: | {{#if: | ||
{{#vardefine: | {{#vardefine:spec|{{#var:spec}}{{#if:{{#var:spec}}|<br/>|<span></span>}} | ||
{{{!}} {{Prettytable|style=float:left;}} | |||
{{{!}} {{Prettytable|style=float: | |||
{{!}}-{{Hl2}} | {{!}}-{{Hl2}} | ||
! Index | ! Index | ||
Line 17: | Line 16: | ||
{{!}} -1 | {{!}} -1 | ||
{{!}}} | {{!}}} | ||
The easiest way to explain how ranges works 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 | === Indexes === | ||
<div style="display:table;"> | |||
<div style="display:inherit;"> | |||
*Positive indexes count from the beginning, the first item being indexed as '''0''', the last as '''(length - 1)'''. | |||
*Negative indexes count from the far end, the first item being indexed as '''-length''', the last as '''-1'''. | |||
</div> | |||
</div> | |||
}} | |||
{{#vardefine:notes|{{#var:notes}}{{#if:{{#var:notes}}|<br/>|<span></span>}} | |||
=== Ranges & Indexes === | |||
The easiest way to explain how ranges works 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. | |||
*If '''{{{1}}}''' <= '''{{{2}}}''' then the range operated on starts at '''{{{1}}}''' and ends at '''{{{2}}}'''. ['''{{{1}}}''', '''{{{2}}}'''] | *If '''{{{1}}}''' <= '''{{{2}}}''' then the range operated on starts at '''{{{1}}}''' and ends at '''{{{2}}}'''. ['''{{{1}}}''', '''{{{2}}}'''] |
Revision as of 15:54, 17 April 2009
#var | value | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
p_start_desc | start index | |||||||||
p_end_desc | end index | |||||||||
spec |
Indexes
| |||||||||
notes |
Ranges & IndexesThe easiest way to explain how ranges works 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. | |||||||||
caveats |
|