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