import functools


def compose(*functions):
    """ Compose functions left-to-right.

    NOTE: This implementation is based on a blog post by Mathieu Larose.
        https://mathieularose.com/function-composition-in-python/

    Parameters
    ----------
    *functions : function
        functions = func_1, func_2, ... func_n
        These should be single-argument functions. If they are not functions of
        a single argument, you can do partial function application using
        `functools.partial` before calling `compose`.

    Returns
    -------
    composition : function
        Composition of the arguments. In other words,
        composition(x) = func_1( func_2( ... func_n(x) ... ) )
    """

    def compose2(f, g):
        return lambda x: f(g(x))

    composition = functools.reduce(compose2, functions)

    return composition