예제 #1
0
def test_tagged_more(c, x, y, z):
    if c == 0:
        return tagged(x)
    elif c > 0:
        return tagged(y)
    else:
        return tagged(z)
예제 #2
0
def countdown(n):
    if n == 0:
        return tagged(None)
    else:
        return tagged(
            Pair(
                n,
                countdown(n - 1)
            )
        )
예제 #3
0
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)
            )
        )
예제 #4
0
def test_tagged_too_many_arguments(x):
    return tagged(x, 1, 2)
예제 #5
0
def test_tagged(x, y, z):
    if x > 0:
        return tagged(y)
    else:
        return tagged(z)