Another typical example is the function
filter
that keeps items for which a predicate function returns true. For example,>>> my_filter(lambda v: v % 2 == 0, [1, 2, 3, 4, 5, 6]) [2, 4, 6] >>> my_filter(lambda v: len(v) > 3, ["c++", "python", "c", "awk", "java"]) ['python', 'java']It is left as an exercise for you to implement
my_filter
;).