[lang-ref] ( filter_with_named_function ) ( python )

def test_filter_with_named_function():
    # filter(fn, items)
    items = [1, 2, 3, 4, 5, 6]

    def is_even(x):
        return x % 2 == 0

    r = list(filter(is_even, items))

    assert r == [2, 4, 6]