def nest_list(f, expr, n):
    """
    returns the list of results of applying f to expr n times

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

    Returns
    -------
    out : list
        returns [f(expr), f(f(expr)), f(f(f(expr))), ...]

    Examples
    --------
    
    >>> xt.nest_list(lambda x:x//2, 1024, 10)
    [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
    
    >>> xt.nest_list(lambda x:x[0], [['a','b'],['c','d']], 2)
    [['a', 'b'], 'a']

    """
    end = []
    for i in range(n):
        expr = f(expr)
        end.append(expr)
    return end
