Question: Using Python; a.Write a recursive function apply_to_all() that takes a function and a list as arguments and returns a list comprising the results of applying
Using Python;
a.Write a recursive function apply_to_all() that takes a function and a list as arguments and returns a list comprising the results of applying the function to each elements of the list.
Example: >>> apply_to_all( sqrt, [4, 9, 16, 25] ) # sqrt = square root function [2, 3, 4, 5]
b.Write a recursive function apply_select() that takes a predicate function and a list as arguments and returns a list of those elements for which the predicate is true. Example: >>> apply_select( is_odd, [2, 3, 5, 8, 9] ) # is_odd = True is num is odd [3, 5, 9] # False otherwise
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
