Difference between revisions of "LlListReplaceList/ko"
Jump to navigation
Jump to search
Nanjido Oh (talk | contribs) (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=...) |
Nanjido Oh (talk | contribs) |
||
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= | |p1_type=list|p1_name=dest|p1_desc=결과 | ||
|p2_type=list|p2_name=src|p2_desc= | |p2_type=list|p2_name=src|p2_desc=원본 | ||
|p3_type=integer|p3_name= | |p3_type=integer|p3_name=end | ||
|p4_type=integer|p4_name= | |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|음의 색인}}을 사용할 때에도 같은 식으로 작동한다. | ||
|caveats=*(결과를 곧바로 다시 이용하는 경우가 아니라면) 함수를 호출하는 것 만으로는 값이 갱신되지 않으며 저장을 할 변수가 있어야 한다. | |||
|caveats=* | |||
:{{{!}} | :{{{!}} | ||
{{LSL DefineRow|''' | {{LSL DefineRow|'''나쁨:'''|<code>llListReplaceList(a, ["c"], 2, 2)</code>}} | ||
{{LSL DefineRow|''' | {{LSL DefineRow|'''좋음:'''|<code>a {{=}} llListReplaceList(a, ["c"], 2, 2)</code>}} | ||
{{!}}} | {{!}}} | ||
* | *같은 목록을 저장할 경우 저장하기 전 목록을 비우는 것이 메모리 사용에 더 효율적이다. | ||
:{{{!}} | :{{{!}} | ||
{{LSL DefineRow|''' | {{LSL DefineRow|'''좋음:'''| <code>a {{=}} llListReplaceList(a, ["c"], 2, 2)</code>}} | ||
{{LSL DefineRow|''' | {{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);// | list b = llListReplaceList(a, ["c"], 2, 2); | ||
//색인 2에서 출발해서 2에서 끝나는 범위를 ["c"]로 치환하고 b에 저장한다. | |||
llOwnerSay("\""+llList2CSV(a) + "\" -> \"" + llList2CSV(b)+"\"");// | llOwnerSay("\""+llList2CSV(a) + "\" -> \"" + llList2CSV(b)+"\"");//변경되는 것을 출력 | ||
// | //출력: "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= | ||
확실한 동작을 위해서는 치환하려는 목록은 너무 많은 원소를 갖고 있어서는 안된다. 단일 항목을 대괄호로 감싸면 단 하나의 원소를 갖는 목록이 만들어진다. | |||
<lsl>list TargetList = ["a", "b", "c", "z", "e"]; | <lsl>list TargetList = ["a", "b", "c", "z", "e"]; | ||
list InsertList = ["d"];</lsl> | list InsertList = ["d"];</lsl> | ||
목록에서 하나의 원소만 치환을 하려면 해당 원소를 지시하는 시작과 끝의 색인을 같게 하면 된다. 이를테면 0, 0은 첫 번째 원소에7, 7 은 8번째 원소에만 작용을 하게 된다. | |||
llListReplaceList와 같이 작동하지만 절편 목록에 대해 그와 같은 일을 하려면 [[ListStridedUpdate/ko|ListStridedUpdate]]를 참고할 것. | |||
|permission | |permission | ||
|sort=ListReplaceList | |sort=ListReplaceList |
Latest revision as of 00:43, 12 April 2009
명세
색인 | 양 | 음 |
---|---|---|
처음 | 0 | -length |
마지막 | length - 1 | -1 |
우선 임의의 음수 색인은 양수 색인으로 먼저 생각한다
|
(마지막 색인보다 큰) 전체 길이 이전의 양의 색인, 또는 (첫 색인보다 전방에 위치한) 시작점 이전의 음의 색인 만이 유효하다. 효과는 예측가능하며 항목들은 어딘가에 실제로 존재하는 것 처럼 다루어지지만, 실은 출력 이전에 모두 삭제된다.
더 자세한 정보는 음의 색인을 참조.
만약 start가 dest의 마지막 색인 보다 크면, 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를 참고할 것.
함께 보기
상세 기록
이 글이 유용하지 않으세요? LSL Wiki의 관련항목이 도움을 줄 수 있을 지도 모릅니다.