diff options
Diffstat (limited to 'cs')
| -rw-r--r-- | cs/core.cs | 6 | ||||
| -rw-r--r-- | cs/stepA_more.cs | 1 |
2 files changed, 7 insertions, 0 deletions
@@ -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)))))))"); |
