Difference between revisions of "LlListFindList/ja"

From Second Life Wiki
Jump to navigation Jump to search
(Initial translation)
 
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
|return_type=integer|p1_type=list|p1_name=src|p2_type=list|p2_name=test
|return_type=integer|p1_type=list|p1_name=src|p2_type=list|p2_name=test
|func_footnote='''src''' において '''test''' が見つからなかった場合は {{HoverText|-1|マイナス1, 0x{{LSL_Hex/Write|-1}}}} が返されます。<br/>
|func_footnote='''src''' において '''test''' が見つからなかった場合は {{HoverText|-1|マイナス1, 0x{{LSL_Hex/Write|-1}}}} が返されます。<br/>
リストの先頭要素のインデックスは {{HoverText|0|ゼロ}} です。
リストの先頭要素のインデックスは {{HoverText|0|ゼロ}} です。<br>
'''test''' が '''src''' の最後のインデックスで見つかると、正のインデックスが返ります (5 つの要素の 5 番目の場合、 4) 。
|func_desc
|func_desc
|return_text='''src''' において最初に '''test''' が出現するインデックス
|return_text='''src''' において最初に '''test''' が出現するインデックス
Line 11: Line 12:
|caveats=*マッチングの際、データ型の一致、大文字/小文字の一致が必須です。
|caveats=*マッチングの際、データ型の一致、大文字/小文字の一致が必須です。
|constants
|constants
|examples=<lsl>list numbers = [1, 2, 3, 4, 5];
|examples=<source lang="lsl2">list numbers = [1, 2, 3, 4, 5];
default
default
{
{
Line 21: Line 22:
             list three_four = llList2List(numbers, index, index + 1);
             list three_four = llList2List(numbers, index, index + 1);
             llOwnerSay(llDumpList2String(three_four, ","));
             llOwnerSay(llDumpList2String(three_four, ","));
             // Object: 3,4
             // オブジェクト: 3,4
         }
         }
     }
     }
}</lsl>
}</source><source lang="lsl2">//2 つの要素をいっぺんに調べ、リストの中のパターンを見つけることもできます。
list avatarsWhoFoundMagicLeaves = ["Fire Centaur","Red Leaf"];
default
{
    state_entry()
    {
        integer index = llListFindList(avatarsWhoFoundMagicLeaves, ["Fire Centaur","Red Leaf"]);
        if (index != -1)
        {
            list output = llList2List(avatarsWhoFoundMagicLeaves, index, index + 1);
            llOwnerSay(llDumpList2String(output, ","));
            // オブジェクト: Fire Centaur, Red Leaf
        }
    }
}</source>
|helpers=
|helpers=
ある要素がリストに含まれているかを簡単に調べるには...
ある要素がリストに含まれているかを簡単に調べるには...
<lsl>if(~llListFindList(myList, (list)item))
<source lang="lsl2">if(~llListFindList(myList, (list)item))
{//存在する場合の処理をここに記述。
{//存在する場合の処理をここに記述。
     // ~(-1) == 0 なので、上の条件式で問題ありません。
     // ~(-1) == 0 なので、上の条件式で問題ありません。
     // != -1 よりもメモリの節約となり、動作も速いです。
     // != -1 よりもバイトコードの節約となり、動作も速いです。
}</lsl>
}</source>
|also_functions=
|also_functions=
{{LSL DefineRow||{{LSLG/ja|llSubStringIndex}}|文字列中の特定のキーワードを検索する}}
{{LSL DefineRow||{{LSLG/ja|llSubStringIndex}}|他の文字列の中で文字列を検索する}}
{{LSL DefineRow||[[User:Void_Singer/Functions#List:_Find_Last_Index|List: Find Last Index]]|入力文字列でヒットした '''最後の''' インスタンスのインデックスを表す整数値を返す}}
{{LSL DefineRow||[[User:Void_Singer/Functions#List:_Multi-Find_Index_.28First_or_Last.29|List: Multi-Find Index (First_or_Last)]]|入力文字列でマッチした要素の '''全部の''' 最初 (または最後) のインデックスを取得する}}
|also_events
|also_events
|also_tests
|also_tests

Latest revision as of 07:12, 25 February 2016

要約

関数: integer llListFindList( list src, list test );

src において最初に test が出現するインデックスを integer で返します。

• list src
• list test

src において test が見つからなかった場合は -1 が返されます。
リストの先頭要素のインデックスは 0 です。
testsrc の最後のインデックスで見つかると、正のインデックスが返ります (5 つの要素の 5 番目の場合、 4) 。

警告

  • マッチングの際、データ型の一致、大文字/小文字の一致が必須です。
All Issues ~ Search JIRA for related Bugs

サンプル

list numbers = [1, 2, 3, 4, 5];
default
{
    state_entry()
    {
        integer index = llListFindList(numbers, [3]);
        if (index != -1)
        {
            list three_four = llList2List(numbers, index, index + 1);
            llOwnerSay(llDumpList2String(three_four, ","));
            // オブジェクト: 3,4
        }
    }
}
//2 つの要素をいっぺんに調べ、リストの中のパターンを見つけることもできます。
list avatarsWhoFoundMagicLeaves = ["Fire Centaur","Red Leaf"];
default
{
    state_entry()
    {
        integer index = llListFindList(avatarsWhoFoundMagicLeaves, ["Fire Centaur","Red Leaf"]);
        if (index != -1)
        {
            list output = llList2List(avatarsWhoFoundMagicLeaves, index, index + 1);
            llOwnerSay(llDumpList2String(output, ","));
            // オブジェクト: Fire Centaur, Red Leaf
        }
    }
}

便利なスニペット

ある要素がリストに含まれているかを簡単に調べるには...

if(~llListFindList(myList, (list)item))
{//存在する場合の処理をここに記述。
    // ~(-1) == 0 なので、上の条件式で問題ありません。
    // != -1 よりもバイトコードの節約となり、動作も速いです。
}

関連項目

関数

•  llSubStringIndex 他の文字列の中で文字列を検索する
•  List: Find Last Index 入力文字列でヒットした 最後の インスタンスのインデックスを表す整数値を返す
•  List: Multi-Find Index (First_or_Last) 入力文字列でマッチした要素の 全部の 最初 (または最後) のインデックスを取得する

特記事項

Search JIRA for related Issues

Signature

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