Example #1
0
 def test_foldl_empty_list(self):
     self.assertEqual(foldl(lambda x, y: x * y, [], 2), 2)
Example #2
0
 def test_foldl_div(self):
     self.assertEqual(
         0, list_ops.foldl(operator.floordiv, [1, 2, 3, 4, 5, 6], 1))
Example #3
0
 def test_foldl_sub(self):
     self.assertEqual(-15, list_ops.foldl(operator.sub, [1, 2, 3, 4, 5], 0))
Example #4
0
 def test_foldl_sum(self):
     self.assertEqual(21, list_ops.foldl(operator.add, [1, 2, 3, 4, 5, 6],
                                         0))
Example #5
0
 def test_foldl_product(self):
     self.assertEqual(720,
                      list_ops.foldl(operator.mul, [1, 2, 3, 4, 5, 6], 1))
Example #6
0
 def test_foldl_product(self):
     self.assertEqual(720, list_ops.foldl(operator.mul, [1, 2, 3, 4, 5, 6], 1))
Example #7
0
 def test_foldl_nonempty_list_floordiv(self):
     self.assertEqual(list_ops.foldl(operator.floordiv, [2, 5], 5), 0)
 def test_foldl_nonempty_list_floordiv(self):
     self.assertEqual(list_ops.foldl(operator.floordiv, [2, 5], 5), 0)
Example #9
0
 def test_foldl_empty_list(self):
     self.assertEqual(list_ops.foldl(operator.mul, [], 2), 2)
 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)
Example #12
0
 def test_foldl_empty_list(self):
     self.assertEqual(foldl(lambda acc, el: el * acc, [], 2), 2)
Example #13
0
 def test_foldl_sub(self):
     self.assertEqual(-15, list_ops.foldl(operator.sub, [1, 2, 3, 4, 5], 0))
Example #14
0
 def test_foldl_div(self):
     self.assertEqual(0, list_ops.foldl(operator.floordiv, [1, 2, 3, 4, 5, 6], 1))
Example #15
0
 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)
Example #16
0
 def test_foldl_nonempty_list_addition(self):
     self.assertEqual(list_ops.foldl(operator.add, [1, 2, 3, 4], 5), 15)
Example #17
0
 def test_foldl_direction_dependent_function_applied_to_non_empty_list(
         self):
     self.assertEqual(foldl(lambda x, y: x // y, [2, 5], 5), 0)
Example #18
0
 def test_foldl_sum(self):
     self.assertEqual(21, list_ops.foldl(operator.add, [1, 2, 3, 4, 5, 6], 0))