def test_zipwith_cons(): # pylint: disable=missing-docstring sl1 = SList([1, 2, 3]) sl2 = SList([2, 3, 4]) res = sl1.map2(operator.add, sl2) exp = SList([3, 5, 7]) assert res == exp
def test_zipwith_nil(): # pylint: disable=missing-docstring sl1 = SList() sl2 = SList() res = sl1.map2(operator.add, sl2) exp = SList() assert res == exp
def vadd(vec1: DSList, vec2: DSList): """ Computes the sum of two vectors. :param vec1: DSList :param vec2: DSList :return: DSList """ return vec1.map2(add, vec2)
def test_zipwith_one_lt(): # pylint: disable=missing-docstring sl1 = SList([2, 3]) sl2 = SList([2, 3, 4]) with pytest.raises(AssertionError): sl1.map2(operator.add, sl2)
def test_map2_non_empty(): # pylint: disable=missing-docstring data = SList([42, 11, 0, -42]) res = data.map2(operator.add, data).to_seq() exp = data.to_seq().map(lambda x: 2 * x) assert res == exp
def test_map2_empty(): # pylint: disable=missing-docstring data = SList() res = data.map2(operator.add, data).to_seq() exp = [] assert res == exp