Пример #1
0
    def test_foldl_order(self):
        """Test that left folds are applied in the correct order.

        E.g., foldl(pow, 2, [1, 2, 3]) should be applied like:
        (2^1) = 2
        (2^2) = 4
        (4^3) = 64
        """
        self.assertEqual(foldl(pow, 2, [1, 2, 3]), 64)
Пример #2
0
 def test_foldl_basic(self):
     """ Test that left folds basically work. """
     self.assertEqual(foldl(add, 2, [1, 2, 3]), 8)