def test_interleave(): assert interleave([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] assert interleave() == [] assert interleave([1, 3], [2, 4]) == [1, 2, 3, 4] assert interleave(repeat(1), [2, 4]) == [1, 2, 1, 4] assert take(5, interleave(powers_of(2), powers_of(3))) == [1, 1, 2, 3, 4] assert take(5, apply(interleave, map(powers_of, [2, 3]))) == [1, 1, 2, 3, 4]
def test_apply(): assert apply(plus) == 0 assert apply(plus, [1, 2, 3]) == 6 assert apply(concat, [[1, 2, 3], [4, 5, 6]]) == [1, 2, 3, 4, 5, 6]
def test_partial(): assert partial(plus)(1, 2, 3) == 6 assert partial(plus, 1)(2, 3) == 6 assert partial(take_last, 2)([1, 2, 3, 4]) == [3, 4] assert apply(partial, [plus, 1, 2, 3])() == 6