Difference between revisions of "LlListReplaceList/ko"

From Second Life Wiki
Jump to navigation Jump to search
(New page: {{LSL_Function/negative index/ko|true|start|end}}{{LSL_Function/ko |func_id=296|func_sleep=0.0|func_energy=10.0 |func=llListReplaceList|return_type=list |p1_type=list|p1_name=dest|p1_desc=...)
 
 
Line 2: Line 2:
|func_id=296|func_sleep=0.0|func_energy=10.0
|func_id=296|func_sleep=0.0|func_energy=10.0
|func=llListReplaceList|return_type=list
|func=llListReplaceList|return_type=list
|p1_type=list|p1_name=dest|p1_desc=destination
|p1_type=list|p1_name=dest|p1_desc=결과
|p2_type=list|p2_name=src|p2_desc=source
|p2_type=list|p2_name=src|p2_desc=원본
|p3_type=integer|p3_name=start
|p3_type=integer|p3_name=end
|p4_type=integer|p4_name=end
|p4_type=integer|p4_name=start
|func_footnote
|func_footnote
|func_desc
|func_desc
|return_text=목록 '''dest'''의 색인 '''start'''에서 '''end'''까지가 '''src'''로 삽입 치환된 새로운 목록
|return_text=목록 '''dest'''의 색인 '''start'''에서 '''end'''까지가 '''src'''로 삽입 치환된 새로운 목록
|spec=<br/>
|spec=<br/>만약 '''start''''''dest'''의 마지막 색인 보다 크면, '''src'''는 빈 원소 없이 '''dest'''의 뒤에 연결된다. 이것을 피하려면 목록의 후미에 빈 원소들을 먼저 생성해서 붙여야 한다. {{LSLGC/ko|Negative Index|음의 색인}}을 사용할 때에도 같은 식으로 작동한다.
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 {{LSLGC|Negative Index|negative indexes}}.
|caveats=*(결과를 곧바로 다시 이용하는 경우가 아니라면) 함수를 호출하는 것 만으로는 값이 갱신되지 않으며 저장을 할 변수가 있어야 한다.  
|caveats=*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.)
:{{{!}}
:{{{!}}
{{LSL DefineRow|'''Bad:'''|<code>llListReplaceList(a, ["c"], 2, 2)</code>}}
{{LSL DefineRow|'''나쁨:'''|<code>llListReplaceList(a, ["c"], 2, 2)</code>}}
{{LSL DefineRow|'''Good:'''|<code>a {{=}} llListReplaceList(a, ["c"], 2, 2)</code>}}
{{LSL DefineRow|'''좋음:'''|<code>a {{=}} llListReplaceList(a, ["c"], 2, 2)</code>}}
{{!}}}
{{!}}}
*If you are storing to the same list, it can be more memory effective to clear the list before you store.
*같은 목록을 저장할 경우 저장하기 전 목록을 비우는 것이 메모리 사용에 더 효율적이다.
:{{{!}}
:{{{!}}
{{LSL DefineRow|'''Good:'''| <code>a {{=}} llListReplaceList(a, ["c"], 2, 2)</code>}}
{{LSL DefineRow|'''좋음:'''| <code>a {{=}} llListReplaceList(a, ["c"], 2, 2)</code>}}
{{LSL DefineRow|'''Better:'''|<code>a {{=}} llListReplaceList((a {{=}} []) + a, ["c"], 2, 2)</code>}}
{{LSL DefineRow|'''더 좋음:'''|<code>a {{=}} llListReplaceList((a {{=}} []) + a, ["c"], 2, 2)</code>}}
{{!}}}
{{!}}}


Line 29: Line 28:
     {
     {
         list a = ["a", "b", "e", "d"];
         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
         list b = llListReplaceList(a, ["c"], 2, 2);
        //색인 2에서 출발해서 2에서 끝나는 범위를 ["c"]로 치환하고 b에 저장한다.


         llOwnerSay("\""+llList2CSV(a) + "\"  ->  \"" + llList2CSV(b)+"\"");//display the change
         llOwnerSay("\""+llList2CSV(a) + "\"  ->  \"" + llList2CSV(b)+"\"");//변경되는 것을 출력
         //Will say: "a, b, e, d"  ->  "a, b, c, d"
         //출력: "a, b, e, d"  ->  "a, b, c, d"
     }
     }
}</lsl>
}</lsl>
|helpers
|helpers
|also_functions=
|also_functions=
{{LSL DefineRow|[[llDeleteSubList]]|}}
{{LSL DefineRow/ko|[[llDeleteSubList]]|}}
{{LSL DefineRow|[[llListInsertList]]|}}
{{LSL DefineRow/ko|[[llListInsertList]]|}}
{{LSL DefineRow|[[llList2List]]|}}
{{LSL DefineRow/ko|[[llList2List]]|}}
|also_events
|also_events
|also_tests=
|also_tests=
Line 45: Line 45:
|also_articles
|also_articles
|notes=
|notes=
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"];
<lsl>list TargetList = ["a", "b", "c", "z", "e"];
list InsertList = ["d"];</lsl>
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.
목록에서 하나의 원소만 치환을 하려면 해당 원소를 지시하는 시작과 끝의 색인을 같게 하면 된다. 이를테면 0, 0은 첫 번째 원소에7, 7 은 8번째 원소에만 작용을 하게 된다.


For a function that will operate as llListReplaceList does, but work on strided lists, see [[ListStridedUpdate]].
llListReplaceList와 같이 작동하지만 절편 목록에 대해 그와 같은 일을 하려면 [[ListStridedUpdate/ko|ListStridedUpdate]]를 참고할 것.
|permission
|permission
|sort=ListReplaceList
|sort=ListReplaceList

Latest revision as of 00:43, 12 April 2009

설명

함수: list llListReplaceList( list dest, list src, integer end, integer start );
296 함수ID
0.0 지연
10.0 에너지

반환되는 값은 목록 dest의 색인 start에서 end까지가 src로 삽입 치환된 새로운 목록.

• list dest 결과
• list src 원본
• integer end end 색인
• integer start start 색인

start & end음의 색인을 지원한다.

명세

색인
처음 0 -length
마지막 length - 1 -1

우선 임의의 음수 색인은 양수 색인으로 먼저 생각한다

  • 만약 start <= end이면 적용 범위는 start에서 시작하여 end에서 끝난다.[start, end]
  • 만약 start > end이면 적용 범위는 0에서 시작하여 end를 지난 뒤 다시start에서 출발하여 -1로 간다. [0, end] + [start, -1]

(마지막 색인보다 큰) 전체 길이 이전의 양의 색인, 또는 (첫 색인보다 전방에 위치한) 시작점 이전의 음의 색인 만이 유효하다. 효과는 예측가능하며 항목들은 어딘가에 실제로 존재하는 것 처럼 다루어지지만, 실은 출력 이전에 모두 삭제된다.

더 자세한 정보는 음의 색인을 참조.

만약 startdest의 마지막 색인 보다 크면, src는 빈 원소 없이 dest의 뒤에 연결된다. 이것을 피하려면 목록의 후미에 빈 원소들을 먼저 생성해서 붙여야 한다. 음의 색인을 사용할 때에도 같은 식으로 작동한다.

주의

  • (결과를 곧바로 다시 이용하는 경우가 아니라면) 함수를 호출하는 것 만으로는 값이 갱신되지 않으며 저장을 할 변수가 있어야 한다.
• 나쁨: llListReplaceList(a, ["c"], 2, 2)
• 좋음: a = llListReplaceList(a, ["c"], 2, 2)
  • 같은 목록을 저장할 경우 저장하기 전 목록을 비우는 것이 메모리 사용에 더 효율적이다.
• 좋음: a = llListReplaceList(a, ["c"], 2, 2)
• 더 좋음: a = llListReplaceList((a = []) + a, ["c"], 2, 2)

예제

<lsl>default {

   state_entry()
   {
       list a = ["a", "b", "e", "d"];
       list b = llListReplaceList(a, ["c"], 2, 2);
       //색인 2에서 출발해서 2에서 끝나는 범위를 ["c"]로 치환하고 b에 저장한다.
       llOwnerSay("\""+llList2CSV(a) + "\"  ->  \"" + llList2CSV(b)+"\"");//변경되는 것을 출력
       //출력: "a, b, e, d"  ->  "a, b, c, d"
   }

}</lsl>

기록

확실한 동작을 위해서는 치환하려는 목록은 너무 많은 원소를 갖고 있어서는 안된다. 단일 항목을 대괄호로 감싸면 단 하나의 원소를 갖는 목록이 만들어진다.

<lsl>list TargetList = ["a", "b", "c", "z", "e"]; list InsertList = ["d"];</lsl>

목록에서 하나의 원소만 치환을 하려면 해당 원소를 지시하는 시작과 끝의 색인을 같게 하면 된다. 이를테면 0, 0은 첫 번째 원소에7, 7 은 8번째 원소에만 작용을 하게 된다.

llListReplaceList와 같이 작동하지만 절편 목록에 대해 그와 같은 일을 하려면 ListStridedUpdate를 참고할 것.

함께 보기

함수

• llDeleteSubList
• llListInsertList
• llList2List

문서

•  Negative_Index

상세 기록

이 글이 유용하지 않으세요? LSL Wiki의 관련항목이 도움을 줄 수 있을 지도 모릅니다.