Пример #1
0
def test_union_nested(x, y):
    if hastype(x, i64):
        return x
    elif hastype(x, f64):
        return y
    else:
        return x[0]
Пример #2
0
def test_union_nested_2(x):
    if hastype(x, i64):
        return x
    elif hastype(x, f64):
        return 1234
    else:
        return x[0]
Пример #3
0
 def f(x):
     if hastype(x, i64):
         return x
     elif hastype(x, f64):
         return f(_to_i64(x))
     elif hastype(x, ai64):
         return 0.0
     elif hastype(x, Point):
         return f(x.x) * f(x.y)
     elif hastype(x, EmptyTuple):
         return 0
     elif hastype(x, Tf4):
         return x
     elif hastype(x, Tuple):
         return f(x[0]) + f(x[1:])
     elif hastype(x, List):
         return 1.0
     elif hastype(x, Thing_ftup):
         return x.contents
     else:
         return 0
Пример #4
0
def test_raise_hastype(x):
    if hastype(x, i32):
        raise Exception("What a terrible type")
    else:
        return x
Пример #5
0
def _interference_helper(x):
    if hastype(x, Tuple):
        return x[0]
    else:
        return x
Пример #6
0
def test_user_switch_hastype(x, y):
    return user_switch(hastype(x, i64), y + 1, y + 2)
Пример #7
0
 def condition(x):
     return hastype(x, i64) and x > 0
Пример #8
0
def test_union(x):
    if hastype(x, i64):
        return x
    else:
        return x[0]
Пример #9
0
def test_hastype(x, y):
    return hastype(x, y)
Пример #10
0
def test_hastype_simple(x):
    return hastype(x, i64)