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