def test_tagged(c, x, y, z): if c > 0: return tagged(x) elif c == 0: return tagged(y) else: return tagged(z)
def countdown(n): if n == 0: return tagged(None) else: return tagged(Pair(n, countdown(n - 1)))
def make_tree(depth, x): if depth == 0: return tagged(x) else: return tagged( Pair(make_tree(depth - 1, x * 2), make_tree(depth - 1, x * 2 + 1)))