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 の項目のキーが結果に適用されるテスト関数の名前(オプション); ; |
Intent ->partition({"a", "b", "c", "c", "e", "z", "x", "c", "e"})
--> {{"x"}, {"z"}, {"e", "e"}, {"c", "c", "c"}, {"b"}, {"a"}}
Intent ->partition({"a", "c", "b", "c", 1, 3, "c", 3, 2, 1})
--> {{2}, {3, 3}, {1, 1}, {"b"}, {"c", "c", "c"}, {"a"}}
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}}
Function integer?(item As Any) As Boolean
integer? = (typeName(item) = :integer)
End Function
Intent >partition({"abc", "123", "24", "xyz", "35"}, key := :length)
--> {{"35", "24"}, {"xyz", "123", "abc"}}
結果は必ずしもこの順序になっていない可能性があります。