def nest(f, expr, n):
    """
    returns the value of f applied to expr n times

    Parameters
    ----------
    f : function
        function to be applied.
    expr : any
        expression f is to be applied to.
    n : int
        number of times.

    Returns
    -------
    expr : any
        result of f(f(f(....expr ...))) nested n deep

    Examples
    --------
    >>> xt.nest(lambda x: x/10, 123456, 4)
    12.3456

    >>> xt.nest(xt.first, [['a','b'],['c','d']], 2)
    'a'
    """
    for i in range(n):
        expr = f(expr)
    return expr
