Execute function for each list element
Executes the provided function once for each list element.
- Use a
for
loop to executefn
for each element initr
.
def for_each(itr, fn): for el in itr: fn(el) for_each([1, 2, 3], print) # 1 2 3
Executes the provided function once for each list element.
for
loop to execute fn
for each element in itr
.def for_each(itr, fn): for el in itr: fn(el) for_each([1, 2, 3], print) # 1 2 3
Executes the provided function once for each list element, starting from the list's last element.
Returns every element that exists in any of the two lists once, after applying the provided function to each element of both.
Returns the difference between two lists, after applying the provided function to each list element of both.
Returns a list of elements that exist in both lists, after applying the provided function to each list element of both.