Difference between revisions of "LlList2ListSlice/ja"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 1: Line 1:
{{LSL_Function/ja
{{LSL_Function/ja
|inject-2={{LSL_Function/negative index|true|start|end|noExclude=*}}{{LSL_Function/stride|stride|slice}}
|inject-2={{LSL_Function/negative/ja index|true|start|end|noExclude=*}}{{LSL_Function/stride/ja|stride|slice}}
|func_id=198|func_sleep=0.0|func_energy=10.0
|func_id=198|func_sleep=0.0|func_energy=10.0
|func=llList2ListSlice
|func=llList2ListSlice
Line 9: Line 9:
|p4_type=integer|p4_name=stride
|p4_type=integer|p4_name=stride
|p5_type=integer|p5_name=slice_index
|p5_type=integer|p5_name=slice_index
|func_footnote=The index of the first entry in the list is {{HoverText|0|zero}}<br>
|func_footnote=リスト内の最初のエントリのインデックスは{{HoverText|0|ゼロ}}です。<br>
The index of the first entry in a slice is {{HoverText|0|zero}}<br>
スライス内の最初のエントリのインデックスは{{HoverText|0|ゼロ}}です。<br>
If {{LSLP|start}}, {{LSLP|end}}, or {{LSLP|slice_index}} are negative they are indexed from end of list.  -1 is last element in the list.  -list_length is the 1st element of the list.<br>
{{LSLP|start}}{{LSLP|end}}、または{{LSLP|slice_index}}が負の場合、リストの末尾からインデックスが付けられます。-1はリストの最後の要素です。-list_lengthはリストの最初の要素です。<br>
If {{LSLP|slice_index}} is negative it is counted from the end of its stride regardless of whether or not the stride exceeds the end of the list.  e.g:  -1 is the last element in a stride.<br>
{{LSLP|slice_index}}が負の場合、リストの末尾からではなく、ストライドの末尾からカウントされます。例:-1はストライドの最後の要素です。<br>
If {{LSLP|start}} > {{LSLP|end}} the range from start to end is treated as an exclusion range.<br>
{{LSLP|start}} > {{LSLP|end}}の場合、startからendまでの範囲は除外範囲として扱われます。<br>
|func_desc
|func_desc
|return_text=of the slice_index'th element of every stride in [[List#Strided_lists|strided list]] whose index is a multiple of {{LSLP|stride}} in the range {{LSLP|start}} to {{LSLP|end}}.
|return_text={{LSLP|start}}から{{LSLP|end}}までの範囲内で、{{LSLP|stride}}の倍数のインデックスを持つ[[List#Strided_lists|ストライドリスト]]の各ストライドにおけるslice_index番目の要素のリスト。
|spec
|spec
|caveats
|caveats
Line 59: Line 59:
}</source>
}</source>


|helpers=*[[User:Fred_Gandt/Scripts/Functions#StrideOfList|StrideOfList]] - Starting from '''start''' and stopping before '''end''' exceeded it skips every '''stride'''-1 items. returns the slice_index element of the stride if its position is less than list length.
|helpers=*[[User:Fred_Gandt/Scripts/Functions#StrideOfList|StrideOfList]] - '''start'''から始めて'''end'''を超える前に、'''stride'''-1アイテムをスキップします。ストライドの位置がリストの長さを下回る場合、ストライドのslice_index番目の要素が返されます。
|also_functions=
|also_functions=
|also_events
|also_events
|also_tests
|also_tests
|also_articles
|also_articles
|notes= If the list is not modulo the stride, elements up to the length of the list will be returned in the final slice matching conditions.  e.g.  a list of 5 elements with a stride of 2 will return 3 elements for a 0,5 range on slice index 0 but only 2 if the slice_index is 1.
|notes= リストがストライドで割り切れない場合、条件に一致する最終のスライスではリストの長さに達するまでの要素が返されます。例:ストライドが2の5つの要素からなるリストは、スライスインデックス0の範囲0,5では3つの要素を返しますが、スライスインデックスが1の場合は2つだけです。
|permission
|permission
|negative_index
|negative_index

Revision as of 13:26, 22 November 2023

要約

関数: list llList2ListSlice( list src, integer start, integer end, integer stride, integer slice_index );

startからendまでの範囲内で、strideの倍数のインデックスを持つストライドリストの各ストライドにおけるslice_index番目の要素のリスト。を list で返します。

• list src
• integer start
• integer end
• integer stride
• integer slice_index

この関数は 飛び石リスト (ストライド リスト) を扱えます。 リスト内の最初のエントリのインデックスは0です。
スライス内の最初のエントリのインデックスは0です。
startend、またはslice_indexが負の場合、リストの末尾からインデックスが付けられます。-1はリストの最後の要素です。-list_lengthはリストの最初の要素です。
slice_indexが負の場合、リストの末尾からではなく、ストライドの末尾からカウントされます。例:-1はストライドの最後の要素です。
start > endの場合、startからendまでの範囲は除外範囲として扱われます。

サンプル

list mylist = [0,1,2,3,4,5,6];
list result_a = llList2ListSlice(mylist,0,-1,3,0); //start at first item in list, go to the end, return 1st slice of every stride of 3
//result_a == [0,3,6]

list result_b = llList2ListSlice(mylist,0,-1,3,1); //start at first item in list, go to the end, return 2nd slice of every stride of 3
//result_b == [1,4]

list result_c = llList2ListSlice(mylist,1,-1,3,1); //start at second item in list, go to the end, return 2nd slice of every stride of 3
//result_c == [2,5]

list result_d = llList2ListSlice(mylist,2,-1,3,-1); //start at first item in list, go to the end, return last slice of every stride of 3
//result_d == [2,5]

list result_e = llList2ListSlice(mylist,4,2,1,0); //4>2 so this is an exclusion. slice indices count from 0 and first element after exclusion. Return every element not in range with a stride of 1
//result_d == [0,1,5,6]
list menu = ["1", "one", "2", "two", "3", "three"];
default
{
    state_entry()
    {
        llListen(10, "", llGetOwner(), "");
    }
    touch_start(integer detected)
    {
        list buttons = llList2ListSlice(menu, 0, -1, 2, 0);
        llDialog(llDetectedKey(0), "choose a number", buttons, 10); //display the digits
    }
    listen(integer channel, string obj, key id, string message)
    {
        integer index = llListFindList(menu, [message]);
        if (index != -1)
        {
            list names = llList2ListSlice(menu, 0, -1, 2, 1);
            llOwnerSay("you chose " + llList2String(names, index ) + " (" + message + ")");
        }
    }
}

便利なスニペット

  • StrideOfList - startから始めてendを超える前に、stride-1アイテムをスキップします。ストライドの位置がリストの長さを下回る場合、ストライドのslice_index番目の要素が返されます。

注意点

リストがストライドで割り切れない場合、条件に一致する最終のスライスではリストの長さに達するまでの要素が返されます。例:ストライドが2の5つの要素からなるリストは、スライスインデックス0の範囲0,5では3つの要素を返しますが、スライスインデックスが1の場合は2つだけです。

特記事項

Search JIRA for related Issues

Signature

function list llList2ListSlice( list src, integer start, integer end, integer stride, integer slice_index );
この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。