def _cons_map(self): from pycket.expand import expand_string from pycket.json import loads ast = to_ast( loads( expand_string(""" (letrec ([range-it (lambda (n a) (if (<= n 0) a (range-it (- n 1) (cons n a))))] [range (lambda (n) (range-it n '()))]) (foldl + 0 (range 1000))) """, wrap=True, stdlib=True))) def interp_w(): val = interpret_one(ast) ov = check_one_val(val) assert isinstance(ov, W_Fixnum) return ov.value assert interp_w() == 500500 self.meta_interp(interp_w, [], listcomp=True, listops=True, backendopt=True)
def main(argv): assert len(argv) > 1 data = readfile_rpython(argv[1]) #data = readfile(argv[1]) json = loads(data) print json print json.tostring() return 0
def _cons_map(self): from pycket.expand import expand_string from pycket.json import loads ast = to_ast(loads(expand_string(""" (letrec ([range-it (lambda (n a) (if (<= n 0) a (range-it (- n 1) (cons n a))))] [range (lambda (n) (range-it n '()))]) (foldl + 0 (range 1000))) """, wrap=True, stdlib=True))) def interp_w(): val = interpret_one(ast) ov = check_one_val(val) assert isinstance(ov, W_Fixnum) return ov.value assert interp_w() == 500500 self.meta_interp(interp_w, [], listcomp=True, listops=True, backendopt=True)