Exemple #1
0
def read_atom(reader:Reader):
    token = reader.next()

    print(token)

    if token.isnumeric():
        return mytypes.MalNumber(float(token))
    elif token[0] == "\"":
        return mytypes.MalString(read_str_(token))
    elif token[0] == ":":
        return mytypes.MalKeyword(token[1:])
    elif token == "true":
        return mytypes.MalBool(True)
    elif token == "false":
        return mytypes.MalBool(False)
    elif token == "nil":
        return mytypes.MalNil()
    else:
        return mytypes.MalSymbol(token)
Exemple #2
0
def fn_atom_q(a):
    return mytypes.MalBool(a.my_type == "atom")
Exemple #3
0
def fn_lte(a, b):
    return mytypes.MalBool(a.content <= b.content)
Exemple #4
0
def fn_gte(a, b):
    return mytypes.MalBool(a.content >= b.content)
Exemple #5
0
def fn_equal(a, b):
    return mytypes.MalBool((a.content == b.content) and (a.my_type == b.my_type))
Exemple #6
0
def fn_empty_q(a):
    return mytypes.MalBool(len(a.content) == 0)
Exemple #7
0
def fn_list_q(a):
    return mytypes.MalBool(a.my_type == "list")