We’re preparing your current view and syncing the latest data.
Given a list of functions [f1, f2, ..., fn], return a function that for any input x returns f1(f2(...(fn(x))...)). Implement function composition functionality that chains the given functions applying them starting from the rightmost function to the leftmost.
A list (array) of functions.
A single function representing the composition of the input functions.
1 <= number of functions <= 1000
Example 1
Input
[x => x + 1, x => x * 2, x => x - 3]
Output
composedFunction(4) returns 3
Explanation
composedFunction(4) = (4 - 3) * 2 + 1 = 3