Difference between revisions of "LlListFindStrided/ja"

From Second Life Wiki
Jump to navigation Jump to search
m
m
 
Line 3: Line 3:
|func_id=201|func_sleep=0.0|func_energy=10.0
|func_id=201|func_sleep=0.0|func_energy=10.0
|return_type=integer
|return_type=integer
|Return_text=index of the first instance of {{LSLP|test}} in {{LSLP|src}} matching conditions.
|Return_text={{LSLP|test}}が条件に一致する{{LSLP|src}}内の最初のインスタンスのインデックス。
|p1_type=list|p1_name=src|p1_desc=what to search in (haystack)
|p1_type=list|p1_name=src|p1_desc=検索対象(ヘイスタック)
|p2_type=list|p2_name=test|p2_desc=what to search for (needle)
|p2_type=list|p2_name=test|p2_desc=検索する内容(ニードル)
|p3_type=integer|p3_name=start|p3_desc=Start of range to search
|p3_type=integer|p3_name=start|p3_desc=検索範囲の開始
|p4_type=integer|p4_name=end|p4_desc=End of range to search
|p4_type=integer|p4_name=end|p4_desc=検索範囲の終了
|p5_type=integer|p5_name=stride|p5_desc=Number of entries per stride within src
|p5_type=integer|p5_name=stride|p5_desc=src内のストライドごとのエントリ数


|func_footnote=If {{LSLP|test}} matching range and stride conditions is not found in {{LSLP|src}}, -1 is returned.<br/>
|func_footnote={{LSLP|test}}{{LSLP|src}}内で範囲とストライドの条件に一致しない場合、-1が返されます。<br/>
The length of {{LSLP|test}} may be equal to or less than {{LSLP|stride}} in order to generate a match.<br/>
{{LSLP|test}}の長さは、一致を生成するために{{LSLP|stride}}と等しいかそれ以下である必要があります。<br/>
The index of the first entry in the list is {{HoverText|0|zero}}<br>
リスト内の最初のエントリのインデックスは{{HoverText|0|ゼロ}}です。<br>
If {{LSLP|test}} is found at the last index in {{LSLP|src}} the positive index is returned (5th entry of 5 returns 4).<br>
{{LSLP|test}}{{LSLP|src}}の最後のインデックスで見つかった場合、正のインデックスが返されます(5つのエントリの5番目は4を返します)。
If {{LSLP|start}} or {{LSLP|end}} is negative, it is counted from the end list. The last element in the list is -1, the first is -list_length
もし{{LSLP|start}}または{{LSLP|end}}が負の場合、それはリストの末尾から数えられます。リスト内の最後の要素は-1で、最初の要素は-list_lengthです。
|func_desc
|func_desc
|spec
|spec
|caveats=
|caveats=
* Strict type matching and case sensitivity is enforced.
* 厳格な型一致と大文字小文字の区別が適用されます。
** "1" != 1
** "1" != 1
** "1.0" != 1.0
** "1.0" != 1.0
Line 24: Line 24:
** "a822ff2b-ff02-461d-b45d-dcd10a2de0c2" != (key)"a822ff2b-ff02-461d-b45d-dcd10a2de0c2"
** "a822ff2b-ff02-461d-b45d-dcd10a2de0c2" != (key)"a822ff2b-ff02-461d-b45d-dcd10a2de0c2"
** "Justice" != "justice"
** "Justice" != "justice"
* If {{LSLP|test}} is an {{HoverText|empty list|[]}} the value returned is {{HoverText|0|zero}} rather than -1.
* もし{{LSLP|test}}{{HoverText|空リスト|[]}}である場合、返される値は{{HoverText|0|ゼロ}}であり、-1ではありません。
|constants
|constants
|examples=<source lang="lsl2">list mylist = ["a",0,"b",1,"c",2,"b",1];
|examples=<source lang="lsl2">list mylist = ["a",0,"b",1,"c",2,"b",1];
Line 117: Line 117:
|helpers=
|helpers=
|also_functions=
|also_functions=
{{LSL DefineRow||[[llSubStringIndex]]|Find a string in another string}}
{{LSL DefineRow||[[llSubStringIndex/ja]]|他の文字列内の文字列を検索する}}
|also_events
|also_events
|also_tests
|also_tests

Latest revision as of 13:32, 22 November 2023

要約

関数: integer llListFindStrided( list src, list test, integer start, integer end, integer stride );

testが条件に一致するsrc内の最初のインスタンスのインデックス。を integer で返します。

• list src 検索対象(ヘイスタック)
• list test 検索する内容(ニードル)
• integer start 検索範囲の開始
• integer end 検索範囲の終了
• integer stride src内のストライドごとのエントリ数

testsrc内で範囲とストライドの条件に一致しない場合、-1が返されます。
testの長さは、一致を生成するためにstrideと等しいかそれ以下である必要があります。
リスト内の最初のエントリのインデックスは0です。
testsrcの最後のインデックスで見つかった場合、正のインデックスが返されます(5つのエントリの5番目は4を返します)。 もしstartまたはendが負の場合、それはリストの末尾から数えられます。リスト内の最後の要素は-1で、最初の要素は-list_lengthです。

警告

  • 厳格な型一致と大文字小文字の区別が適用されます。
    • "1" != 1
    • "1.0" != 1.0
    • 1 != 1.0
    • "a822ff2b-ff02-461d-b45d-dcd10a2de0c2" != (key)"a822ff2b-ff02-461d-b45d-dcd10a2de0c2"
    • "Justice" != "justice"
  • もしtest空リストである場合、返される値は0であり、-1ではありません。
All Issues ~ Search JIRA for related Bugs

サンプル

list mylist = ["a",0,"b",1,"c",2,"b",1];

integer result_a = llListFindStrided(mylist, ["b"], 0, -1, 1); //Stride 1 full range functionally equivalent to llListFindList(mylist,"b");
//result_a = 2

integer result_b = llListFindStrided(mylist, ["b",1], 2, -1, 1); //Inclusive range for start and end will find 2nd list in list
//result_b = 2

integer result_e = llListFindStrided(mylist, ["b"], 3, -1, 1); //The first "b" is at index 2 and will be skipped by starting at 3
//result_c = 6

integer result_d = llListFindStrided(mylist, ["b",1], 2, -1, 1); //Inclusive range for start and end will find 2nd item in list
//result_d = 2

integer result_e = llListFindStrided(mylist, ["b",1], 3, -1, 1); //The first "b",1 series is at index 2 and will be skipped by starting at 3
//result_e = 6

integer result_f = llListFindStrided(mylist, ["b",1], 3, -2, 1); //The first "b",1 series is at index 2 and will be skipped by starting at 3.  The second ["b",1] set exceeds the range criteria of the search.
//result_f = -1

integer result_g = llListFindStrided(mylist, ["b",2], 0, -1, 1); //No consecutive elements match ["b",2]
//result_g = -1

integer result_h = llListFindStrided(mylist, ["c"], 0, -1, 2); //With a stride of 2, "c" will be found.
//result_h = 4

integer result_i = llListFindStrided(mylist, ["c"], 0, -1, 3); //With a stride of 3, "c" won't be found.
//result_i = -1

integer result_j = llListFindStrided(mylist, ["c"], 0, -1, 4); //With a stride of 4, "c" will be found.
//result_j = 4

integer result_k = llListFindStrided(mylist, ["c"], 1, -1, 2); //While the stride is even, starting at the 2nd element will miss this stride.
//result_k = -1
list numbers = [1, 2, 3, 4, 5];
default
{
    state_entry()
    {
        integer index = llListFindStrided(numbers, [3], 0, -1, 1);  //Functionally identical to llListFindList(numbers, [3]);
        if (index != -1)
        {
            list three_four = llList2List(numbers, index, index + 1);
            llOwnerSay(llDumpList2String(three_four, ","));
            // Object: 3,4
        }
    }
}
//You can also search for two items at once to find a pattern in a list
list avatarsWhoFoundMagicLeaves = ["Water Duck", "Green Ham", "Fire Centaur","Red Leaf"];
default
{
    state_entry()
    {
        integer index = llListFindStrided(avatarsWhoFoundMagicLeaves, ["Fire Centaur","Red Leaf"],0,-1,2);
        if (index != -1)
        {
            list output = llList2List(avatarsWhoFoundMagicLeaves, index, index + 1);
            llOwnerSay(llDumpList2String(output, ","));
            // Object: Fire Centaur, Red Leaf
        }
    }
}
//It's nearly a database
list food_db = ["FIRSTNAME", "LASTNAME", "FAVORITE FOOD", "ALLERGIES", 
                                   "Awesome", "Resident","Apples",0,
                                   "Charlie", "Kites", "Peanuts", "dogs",
                                   "Cool", "McLastname", "Burgers","peanuts"];
default
{
    state_entry()
    {
        list potential_allergen = ["peanuts"];
        integer any_allergies = llListFindStrided(food_db, potential_allergen,4,-1,4);
        if (any_allergies != -1)
        {
            llOwnerSay("Every can eat it");
        }
        else
        {
            list output = llList2List(food_db, any_allergens - 3, any_allergens - 2);
            llOwnerSay(llDumpList2String(output, " ")+" is allergic to it!");
            // Object: Cool McLastName is allergic to peanuts
        }
    }
}

関連項目

関数

•  llSubStringIndex/ja 他の文字列内の文字列を検索する

特記事項

Search JIRA for related Issues

Signature

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