def add_or_delete(old, new, add_fun, del_fun):
    """
    Given an 'old' and 'new' list, figure out the intersections and invoke
    'add_fun' against every element that is not in the 'old' list and 'del_fun'
    against every element that is not in the 'new' list.

    Returns a tuple where the first element is the list of elements that were
    added and the second element consisting of elements that were deleted.
    """
    old_set = set(old)
    new_set = set(new)
    to_delete = old_set - new_set
    to_add = new_set - old_set
    for elem in to_delete:
        del_fun(elem)
    for elem in to_add:
        add_fun(elem)
    return to_add, to_delete