def update(fun, arr):
    """update all items using function"""
    for val in arr:
        if val.data is not None:
            val.data.update(fun(val))
        else:
            val.update(fun(val))
        yield val
