Wrap Functions
You are asked to write a function
wrap_functions
which takes an arbitrary number of function arguments and a number n
. The wrap_functions
should return a list of results obtained by applying each input function to the number n
.The input to the function consists of one integer
n
(as the last argument) and one or more functions.The function should return a list of results, each representing the result of applying one of the input functions to
n
.Input | Output |
wrap_functions(lambda x: x**2, lambda x: x+10, lambda x: x%2, 5) | [25, 15, 1] |
Explanation: The functions in the input are lambda functions: The first function squares its input, the second function adds 10 to its input, and the third function returns the modulus of its input with respect to 2.
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB