test_irc.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码
def test_foldr(self):
        """
        Apply a function of two arguments cumulatively to the items of
        a sequence, from right to left, so as to reduce the sequence to
        a single value.
        """
        self.assertEqual(
            irc._foldr(operator.sub, 0, [1, 2, 3, 4]),
            -2)

        def insertTop(l, x):
            l.insert(0, x)
            return l

        self.assertEqual(
            irc._foldr(insertTop, [], [[1], [2], [3], [4]]),
            [[[[[], 4], 3], 2], 1])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号