def test_chain():
    rl = chain(posdec, posdec)
    assert rl(5) == 3
    assert rl(1) == 0
Esempio n. 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)
Esempio n. 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))
Esempio n. 4
0
def test_chain():
    rl = chain(posdec, posdec)
    assert rl(5) == 3
    assert rl(1) == 0