Sponsored Reserved space — layout preview until AdSense is connected
medium +20 pts

Function composition

Compose right-to-left.

Implement `compose(*fns)` that accepts any number of functions and returns their composition applied right-to-left.

Constraints

1 ≤ len(fns) ≤ 10. All functions are unary.

Example

>>> double = lambda x: x * 2
>>> add_one = lambda x: x + 1
>>> compose(double, add_one)(5)
12
20 points ~18 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

reduce(lambda f, g: lambda x: f(g(x)), fns).
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.
Sponsored Reserved space — layout preview until AdSense is connected