removeIf?()

概要

関数 fun が True を返すすべてのメンバを削除し、 list のコピーを返します。

構文

removeIf? ( fun As Name, _
            list As List ) As List 
引数 [タイプ] 説明
fun Name 適用する関数の名前です。この関数は boolean を返す必要があります。
list List テスト関数が適用される引数の list をクリックします。

例 1

空のサブリストを削除する
Intent >removeIf(empty?, { {:a}, {:b}, {}, {:d} }) 
--> {{:a}, {:b}, {:d}}
この例では、すべての空のサブリストが削除されます。 この場合、入力 list で 3 番目の項目のみが削除されます。

例 2

カスタム関数を使用する
Intent >removeIf(integer?, {:a, :c, "b", :c, 1.1, 3, :c, 3, 2, 1}) 
--> {:a, :c, "b", :c, 1.1, :c} 
この例では、次のカスタム関数を使用して非整数のみが返されます。
Function integer?(item as Any) as Boolean 
    integer? = (typeName(item) = :integer) 
End Function 

例 3

integer list 要素では、組み込みのシステム関数を使用します。
Intent >removeIf(:even?, {1, 2, 3, 4, 5, 6, 7, 8}) 
--> { 1, 3, 5, 7 }