LlListReplaceList/ko
명세
색인 | 양 | 음 |
---|---|---|
처음 | 0 | -length |
마지막 | length - 1 | -1 |
우선 임의의 음수 색인은 양수 색인으로 먼저 생각한다
|
(마지막 색인보다 큰) 전체 길이 이전의 양의 색인, 또는 (첫 색인보다 전방에 위치한) 시작점 이전의 음의 색인 만이 유효하다. 효과는 예측가능하며 항목들은 어딘가에 실제로 존재하는 것 처럼 다루어지지만, 실은 출력 이전에 모두 삭제된다.
더 자세한 정보는 음의 색인을 참조.
If start is past the end of dest, then src is appended to dest, it will not add null entries. To avoid this, create empty elements in the list first. A similar outcome occurs when using negative indexes.
주의
- Just calling the function will not update the variable. You must store it (unless of course you are planning to act on the results straightway.)
• Bad: llListReplaceList(a, ["c"], 2, 2)
• Good: a = llListReplaceList(a, ["c"], 2, 2)
- If you are storing to the same list, it can be more memory effective to clear the list before you store.
• Good: a = llListReplaceList(a, ["c"], 2, 2)
• Better: a = llListReplaceList((a = []) + a, ["c"], 2, 2)
예제
<lsl>default {
state_entry() { list a = ["a", "b", "e", "d"]; list b = llListReplaceList(a, ["c"], 2, 2);//replace the range starting and ending at index 2 with ["c"] and store it into b
llOwnerSay("\""+llList2CSV(a) + "\" -> \"" + llList2CSV(b)+"\"");//display the change //Will say: "a, b, e, d" -> "a, b, c, d" }
}</lsl>
기록
To be clear, the list you are replacing in doesn't have to actually be a list of many elements. It can be a single item that you make into a single element list just by placing square brackets around it.
<lsl>list TargetList = ["a", "b", "c", "z", "e"]; list InsertList = ["d"];</lsl>
To act on a single element in a list, just quote its place in the list as both start and end. For instance, 0, 0 would act only on the first element in the list; 7,7 would act only on the 8th element.
For a function that will operate as llListReplaceList does, but work on strided lists, see ListStridedUpdate.