partition()

概要

lists list list には、パーティションのメンバーは、キー、テスト条件を満たす list のメンバーが含まれます。 サブセットの順序、それらの要素の順序のどちらにも依存する必要がありません。

構文

partition ( list As List, _
            Optional key As Name = :Identity, _
            Optional test As Name = :Equal) As List 
引数 [タイプ] 説明
list List パーティションに list
key Name 既定の :Identity list 内の各項目で呼び出される関数の name [オプション]をクリックします。 この関数の戻り値をテスト関数を使用して比較します。
test Name lists [ 既定]:Equal の項目のキーが結果に適用されるテスト関数の名前(オプション); ;

例 1

Intent ->partition({"a", "b", "c", "c", "e", "z", "x", "c", "e"}) 
--> {{"x"}, {"z"}, {"e", "e"}, {"c", "c", "c"}, {"b"}, {"a"}} 

例 2

Intent ->partition({"a", "c", "b", "c", 1, 3, "c", 3, 2, 1}) 
--> {{2}, {3, 3}, {1, 1}, {"b"}, {"c", "c", "c"}, {"a"}} 

例 3

Intent ->partition({:a, :c, "b", :c, 1.1, 3, :c, 3, 2, 1}, key := :integer?) 
--> {{ 1, 2, 3, 3}, {c, 1.1, c, "b", c, a}} 
この例では、項目の 2 つの lists - 整数、次のカスタム関数を使用して非整数で list を持つ list に分割されました。
Function integer?(item As Any) As Boolean 
    integer? = (typeName(item) = :integer) 
End Function 

例 4

Intent >partition({"abc", "123", "24", "xyz", "35"}, key := :length) 
--> {{"35", "24"}, {"xyz", "123", "abc"}} 
結果は必ずしもこの順序になっていない可能性があります。