def test_foldl_empty_list(self): self.assertEqual(foldl(lambda x, y: x * y, [], 2), 2)
def test_foldl_div(self): self.assertEqual( 0, list_ops.foldl(operator.floordiv, [1, 2, 3, 4, 5, 6], 1))
def test_foldl_sub(self): self.assertEqual(-15, list_ops.foldl(operator.sub, [1, 2, 3, 4, 5], 0))
def test_foldl_sum(self): self.assertEqual(21, list_ops.foldl(operator.add, [1, 2, 3, 4, 5, 6], 0))
def test_foldl_product(self): self.assertEqual(720, list_ops.foldl(operator.mul, [1, 2, 3, 4, 5, 6], 1))
def test_foldl_nonempty_list_floordiv(self): self.assertEqual(list_ops.foldl(operator.floordiv, [2, 5], 5), 0)
def test_foldl_empty_list(self): self.assertEqual(list_ops.foldl(operator.mul, [], 2), 2)
def test_foldl_nonempty_list_addition(self): self.assertEqual(list_ops.foldl(operator.add, [1, 2, 3, 4], 5), 15)
def test_foldl_empty_list(self): self.assertEqual(foldl(lambda acc, el: el * acc, [], 2), 2)
def test_foldl_div(self): self.assertEqual(0, list_ops.foldl(operator.floordiv, [1, 2, 3, 4, 5, 6], 1))
def test_foldl_direction_independent_function_applied_to_non_empty_list( self): self.assertEqual(foldl(lambda x, y: x + y, [1, 2, 3, 4], 5), 15)
def test_foldl_direction_dependent_function_applied_to_non_empty_list( self): self.assertEqual(foldl(lambda x, y: x // y, [2, 5], 5), 0)