def test_chain():
    rl = chain(posdec, posdec)
    assert rl(5) == 3
    assert rl(1) == 0
示例#2
0
def bottom_up(rule, fns=basic_fns):
    """ Apply a rule down a tree running it on the bottom nodes first """
    return chain(lambda expr: sall(bottom_up(rule, fns), fns)(expr), rule)
示例#3
0
def top_down(rule, fns=basic_fns):
    """ Apply a rule down a tree running it on the top nodes first """
    return chain(rule, lambda expr: sall(top_down(rule, fns), fns)(expr))
示例#4
0
def test_chain():
    rl = chain(posdec, posdec)
    assert rl(5) == 3
    assert rl(1) == 0