Write a function that takes a list lst
and a function handler fun
and returns another list containing only the elements of lst
that satisfy the condition given by fun
. The function fun
takes one argument and returns a boolean (True or False).
list_filter([1,2,3,4,5,6,7], lambda x: x%2 == 0) -> [2,4,6]
list_filter([1,2,3,4,5,6,7], lambda x: x/2 > 2) -> [6,7]