How to add your knowledge

removeIf?()

    Table of contents
    1. 1. Synopsis
    2. 2. Syntax
    3. 3. Example 1
    4. 4. Example 2
    5. 5. Example 3

    Synopsis

    Return a copy of the list, having removed all members for which the function fun returns True.

    Syntax

    removeIf? ( fun As Name, _
                list As List ) As List 
    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.

    Example 1

    Removing empty sublists

    Intent >removeIf(empty?, { {:a}, {:b}, {}, {:d} }) 
    --> {{:a}, {:b}, {:d}}
    In this example, all empty sublists are removed. In this case, this results in the removal of only the third item in the input list.

    Example 2

    Using a custom function

    Intent >removeIf(integer?, {:a, :c, "b", :c, 1.1, 3, :c, 3, 2, 1}) 
    --> {:a, :c, "b", :c, 1.1, :c} 

    In this example, only non-integers were returned using the following custom function.

    Function integer?(item as Any) as Boolean 
        integer? = (typeName(item) = :integer) 
    End Function 

    Example 3

    Using a built-in system function with integer list elements

    Intent >removeIf(:even?, {1, 2, 3, 4, 5, 6, 7, 8}) 
    --> { 1, 3, 5, 7 }