aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/core.py3
-rw-r--r--python/stepA_more.py3
2 files changed, 4 insertions, 2 deletions
diff --git a/python/core.py b/python/core.py
index 54737aa..d10047d 100644
--- a/python/core.py
+++ b/python/core.py
@@ -1,4 +1,4 @@
-import copy
+import copy, time
from itertools import chain
import mal_types as types
@@ -130,6 +130,7 @@ ns = {
'-': lambda a,b: a-b,
'*': lambda a,b: a*b,
'/': lambda a,b: int(a/b),
+ 'time-ms': lambda : int(time.time() * 1000),
'list': types._list,
'list?': types._list_Q,
diff --git a/python/stepA_more.py b/python/stepA_more.py
index fa79ec3..e4bc768 100644
--- a/python/stepA_more.py
+++ b/python/stepA_more.py
@@ -58,7 +58,7 @@ def eval_ast(ast, env):
def EVAL(ast, env):
while True:
- #print("EVAL %s" % ast)
+ #print("EVAL %s" % printer._pr_str(ast))
if not types._list_Q(ast):
return eval_ast(ast, env)
@@ -150,6 +150,7 @@ for k, v in core.ns.items(): repl_env.set(k, v)
repl_env.set('eval', lambda ast: EVAL(ast, repl_env))
# core.mal: defined using the language itself
+REP("(def! *host-language* \"python\")")
REP("(def! not (fn* (a) (if a false true)))")
REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
REP("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")