Пример #1
0
    def test_split_first(self):
        def func(b):
            return b % 2;
        arrow = split() >> FunctionArrow(func).first()

        value = 7
        target = (func(value), value)
        result = arrow(value)

        self.assertEquals(target, result)
Пример #2
0
    def test_split_unsplit(self):
        #           +------> f ---------+
        #           |                   v
        # 8 ---> (split)          (unsplit (op)) ----> 29
        #           |                   ^
        #           +------> g ---------+
        arrow = split() >> FunctionArrow(lambda b : b / 2).first() >> FunctionArrow(lambda b : (3 * b) + 1).second() >> unsplit(lambda b, c: b + c)
        value = 8
        target = 29
        result = arrow(value)

        self.assertEquals(target, result)