Difference between revisions of "Template:LSL Function/negative index/range"
Jump to navigation
Jump to search
m |
m |
||
Line 6: | Line 6: | ||
*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}}}'''] | ||
*<span id="exclusion_range"></span>If '''{{{1}}}''' > '''{{{2}}}''' then the range operated on starts at '''0''' and goes to '''{{{2}}}''' and then starts again at '''{{{1}}}''' and goes to '''-1'''. ['''0''', '''{{{2}}}'''] + ['''{{{1}}}''', '''-1'''] | *<span id="exclusion_range">Exclusion range</span>: If '''{{{1}}}''' > '''{{{2}}}''' then the range operated on starts at '''0''' and goes to '''{{{2}}}''' and then starts again at '''{{{1}}}''' and goes to '''-1'''. ['''0''', '''{{{2}}}'''] + ['''{{{1}}}''', '''-1'''] | ||
**If '''{{{2}}}''' is a negative index past the beginning, than the operating range would be ['''{{{1}}}''', '''-1''']. | **If '''{{{2}}}''' is a negative index past the beginning, than the operating range would be ['''{{{1}}}''', '''-1''']. | ||
**If '''{{{2}}}''' is a positive index past the end, than the operating range would be ['''0''', '''{{{2}}}''']. | **If '''{{{2}}}''' is a positive index past the end, than the operating range would be ['''0''', '''{{{2}}}''']. |
Revision as of 00:08, 5 September 2011
#var | value |
---|---|
p_start_desc | start index |
p_end_desc | end index |
spec | |
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 |