Ejemplo n.º 1
0
def macro_Q(args): return wrap_tf(types._function_Q(args[0]) and args[0].ismacro)


# String functions
def pr_str(args):
Ejemplo n.º 2
0
def function_Q(args): return wrap_tf(types._function_Q(args[0]) and not args[0].ismacro)
def macro_Q(args): return wrap_tf(types._function_Q(args[0]) and args[0].ismacro)
Ejemplo n.º 3
0
 'false?':
 types._false_Q,
 'number?':
 types._number_Q,
 'string?':
 types._string_Q,
 'symbol':
 types._symbol,
 'symbol?':
 types._symbol_Q,
 'keyword':
 types._keyword,
 'keyword?':
 types._keyword_Q,
 'fn?':
 lambda x: (types._function_Q(x) and not hasattr(x, '_ismacro_')),
 'macro?':
 lambda x:
 (types._function_Q(x) and hasattr(x, '_ismacro_') and x._ismacro_),
 'pr-str':
 pr_str,
 'str':
 do_str,
 'prn':
 prn,
 'println':
 println,
 'readline':
 lambda prompt: mal_readline.readline(prompt),
 'read-string':
 reader.read_str,
Ejemplo n.º 4
0
    return atm.val


ns = { 
        '=': types._equal_Q,
        'throw': throw,
        'nil?': types._nil_Q,
        'true?': types._true_Q,
        'false?': types._false_Q,
        'number?': types._number_Q,
        'string?': types._string_Q,
        'symbol': types._symbol,
        'symbol?': types._symbol_Q,
        'keyword': types._keyword,
        'keyword?': types._keyword_Q,
        'fn?': lambda x: (types._function_Q(x) and not hasattr(x, '_ismacro_')),
        'macro?': lambda x: (types._function_Q(x) and
                             hasattr(x, '_ismacro_') and
                             x._ismacro_),

        'pr-str': pr_str,
        'str': do_str,
        'prn': prn,
        'println': println,
        'readline': lambda prompt: mal_readline.readline(prompt),
        'read-string': reader.read_str,
        'slurp': lambda file: open(file).read(),
        '<':  lambda a,b: a<b,
        '<=': lambda a,b: a<=b,
        '>':  lambda a,b: a>b,
        '>=': lambda a,b: a>=b,
Ejemplo n.º 5
0
Archivo: core.py Proyecto: kanaka/mal
    return atm.val


ns = { 
        '=': types._equal_Q,
        'throw': throw,
        'nil?': types._nil_Q,
        'true?': types._true_Q,
        'false?': types._false_Q,
        'number?': types._number_Q,
        'string?': types._string_Q,
        'symbol': types._symbol,
        'symbol?': types._symbol_Q,
        'keyword': types._keyword,
        'keyword?': types._keyword_Q,
        'fn?': lambda x: (types._function_Q(x) and not hasattr(x, '_ismacro_')),
        'macro?': lambda x: (types._function_Q(x) and
                             hasattr(x, '_ismacro_') and
                             x._ismacro_),

        'pr-str': pr_str,
        'str': do_str,
        'prn': prn,
        'println': println,
        'readline': lambda prompt: mal_readline.readline(prompt),
        'read-string': reader.read_str,
        'slurp': lambda file: open(file).read(),
        '<':  lambda a,b: a<b,
        '<=': lambda a,b: a<=b,
        '>':  lambda a,b: a>b,
        '>=': lambda a,b: a>=b,