Return a copy of the input list , having removed all members for which the function fun returns False .
removeIfNot ( fun As Name, _ list As List ) As Any
Argument | Type | Description |
---|---|---|
fun | Name | The name of the function to apply; the function must return a boolean . |
list | List | The list of arguments to which the test function will be applied. |
Intent >removeIfNot(:empty?, {{}, {:b}, {}, {:d}}) --> {{}, {}}Returns only empty lists in a list of lists . That is, the non-empty sublists have been removed.
Intent >removeIfNot(string?, {:a, :c, "b", :d, 3, {3}, "3", 2, 1}) --> {"b", "3"}
Function string?(item As Any) As Boolean string? = (typeName(item) = :string) End Function
Intent >removeIfNot(:even?, {1, 2, 3, 4, 5, 6, 7, 8}) --> {2, 4, 6, 8}Here, the odd (not even) items have been removed from the result.