diff options
Diffstat (limited to 'js')
| -rw-r--r-- | js/core.js | 5 | ||||
| -rw-r--r-- | js/stepA_more.js | 1 |
2 files changed, 6 insertions, 0 deletions
@@ -43,6 +43,10 @@ function slurp(f) { } +// Number functions +function time_ms() { return new Date().getTime(); } + + // Hash Map functions function assoc(src_hm) { var hm = types._clone(src_hm); @@ -166,6 +170,7 @@ var ns = {'type': types._obj_type, '-' : function(a,b){return a-b;}, '*' : function(a,b){return a*b;}, '/' : function(a,b){return a/b;}, + "time-ms": time_ms, 'list': types._list, 'list?': types._list_Q, diff --git a/js/stepA_more.js b/js/stepA_more.js index 06eb43d..a2035dc 100644 --- a/js/stepA_more.js +++ b/js/stepA_more.js @@ -164,6 +164,7 @@ for (var n in core.ns) { repl_env.set(n, core.ns[n]); } repl_env.set('eval', function(ast) { return EVAL(ast, repl_env); }); // core.mal: defined using the language itself +rep("(def! *host-language* \"javascript\")") 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)))))))"); |
