Пример #1
0
def test_reverse():
    assert reverse(take(3, natural_numbers())) == [2, 1, 0]
    assert reverse([0, 1, 2]) == [2, 1, 0]
    assert reverse([]) == []

    x = [1, 2, 3, 4, 5]
    y = reverse(x)
    assert x == [1, 2, 3, 4, 5]
Пример #2
0
 def _function(*args, **kwargs):
     return reduce(
         lambda acc, f: f(acc),
         reverse(but_last(fs)),
         last(fs)(*args, **kwargs))