def symmetric_difference_with(predicate, first, second):
    """Finds the set (i.e. no duplicates) of all elements contained in the first or
    second list, but not both. Duplication is determined according to the value
    returned by applying the supplied predicate to two list elements"""
    return concat(
        difference_with(predicate, first, second),
        difference_with(predicate, second, first),
    )
Ejemplo n.º 2
0
def test_difference_with_curry():
    assert_equal(difference_with(complement(cmp))(l1, l1), [])
    assert_equal(difference_with(cmp)(l2)(l1), [{"a": 4}])
Ejemplo n.º 3
0
def test_difference_with():
    assert_equal(difference_with(cmp, l1, l2), [{"a": 1}, {"a": 2}])
    assert_equal(difference_with(cmp, l1, l1), [])
    assert_equal(difference_with(cmp, l2, l1), [{"a": 4}])