Example #1
0
    def test_functor_2nd_low(self):
        seq = Seq(1, 2, 3, 4, 5)

        def f(x):
            return x + 1

        def g(x):
            return x * 2

        self.assertEqual(seq.map(lambda x: f(g(x))), seq.map(g).map(f))
Example #2
0
    def test_functor_1st_low(self):
        seq = Seq(1, 2, 3, 4, 5)

        def identity(x):
            return x

        self.assertEqual(seq.map(identity), identity(seq))
Example #3
0
    def test_applicative_1st_low(self):
        seq = Seq(1, 2, 3, 4, 5)

        def f(x):
            return x + 1

        self.assertEqual(seq.ap(Seq(f)), seq.map(f))