示例#1
0
def addition(*args):
    """Adds any quantity of numbers"""

    def _initial_value():
        return None if not args else 0

    return reduce(_execute, flatten(args), _initial_value())
示例#2
0
def test_flatten_nested_lists():
    assert flatten([[[1, 2, 3]], 1]) == [1, 2, 3, 1]
示例#3
0
def test_flatten_a_flattened_list():
    assert flatten([1, 2, 3, 4]) == [1, 2, 3, 4]
示例#4
0
def test_flatten_list_and_number():
    assert flatten([1, [2, 3, 4]]) == [1, 2, 3, 4]
示例#5
0
def test_flatten_an_empty_list():
    assert flatten([]) == []