Difference between revisions of "Template:LSL Function/negative index/range"

From Second Life Wiki
Jump to navigation Jump to search
Line 22: Line 22:
*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 '''{{{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''']
{{!}}}
{{!}}}
Positive indexes past the length, or negative indexes past the beginning are valid. The effects are predictable, the values are treated as if they were there but were removed.
Positive indexes past the length, or negative indexes past the beginning are valid. The effects are predictable, the values are treated as if they were there but were removed just before output.


See {{LSLGC|Negative_Index#Range Functions|negative indexes}} for more information.
See {{LSLGC|Negative_Index#Range Functions|negative indexes}} for more information.
}}<noinclude>{{#var:spec}}</noinclude>
}}<noinclude>{{#var:spec}}</noinclude>

Revision as of 18:42, 6 March 2007

Index Positive Negative
First 0 -length
Last length - 1 -1

Mentally first translate any negative indexes into positive indexes

  • 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 0 and goes to {{{2}}} and then starts again at {{{1}}} and goes to -1. [0, {{{2}}}] + [{{{1}}}, -1]

Positive indexes past the length, or negative indexes past the beginning are valid. The effects are predictable, the values are treated as if they were there but were removed just before output.

See negative indexes for more information.