From db4c329aff4621e05b92a55be4f18173f5a4f655 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Thu, 17 Apr 2014 21:49:07 -0500 Subject: All: perf test, Makefile refactor, add *host-language* Other: - bash,make,postscript: quasiquote of vectors - Fix Java slurp - add time function to core.mal - switches on *host-language* for make time-secs vs time-ms - Ignore */experiments directories --- cs/core.cs | 6 ++++++ cs/stepA_more.cs | 1 + 2 files changed, 7 insertions(+) (limited to 'cs') diff --git a/cs/core.cs b/cs/core.cs index 62a121c..7cfb772 100644 --- a/cs/core.cs +++ b/cs/core.cs @@ -36,6 +36,11 @@ namespace Mal { a => a[0] is MalSymbol ? True : False); + // Number functions + static MalFunction time_ms = new MalFunction( + a => new MalInteger((int)( + DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond))); + // String functions static public MalFunction pr_str = new MalFunction( a => new MalString(printer._pr_str_args(a, " ", true)) ); @@ -265,6 +270,7 @@ namespace Mal { {"-", new MalFunction(a => (MalInteger)a[0] - (MalInteger)a[1])}, {"*", new MalFunction(a => (MalInteger)a[0] * (MalInteger)a[1])}, {"/", new MalFunction(a => (MalInteger)a[0] / (MalInteger)a[1])}, + {"time-ms", time_ms}, {"list", new MalFunction(a => new MalList(a.getValue()))}, {"list?", list_Q}, diff --git a/cs/stepA_more.cs b/cs/stepA_more.cs index cbbc91f..dbbf53d 100644 --- a/cs/stepA_more.cs +++ b/cs/stepA_more.cs @@ -234,6 +234,7 @@ namespace Mal { repl_env.set("eval", new MalFunction(a => EVAL(a[0], repl_env))); // core.mal: defined using the language itself + RE(repl_env, "(def! *host-language* \"c#\")"); RE(repl_env, "(def! not (fn* (a) (if a false true)))"); RE(repl_env, "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"); RE(repl_env, "(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)))))))"); -- cgit v1.2.3