aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-01-30 12:38:32 -0500
committerChouser <chouser@n01se.net>2015-01-30 12:54:43 -0500
commitf5fc0c98ee9c140077469146bbc9d8a77fdb02f3 (patch)
tree698acd986d10a6227ad42a0eaf2671878f26a341
parent2b8e0ea42046505635e8f4c9d96e594c595948c2 (diff)
downloadmal-f5fc0c98ee9c140077469146bbc9d8a77fdb02f3.tar.gz
mal-f5fc0c98ee9c140077469146bbc9d8a77fdb02f3.zip
OCaml: Add time-ms
-rw-r--r--ocaml/Makefile2
-rw-r--r--ocaml/core.ml3
2 files changed, 4 insertions, 1 deletions
diff --git a/ocaml/Makefile b/ocaml/Makefile
index e5b0ac2..72d159a 100644
--- a/ocaml/Makefile
+++ b/ocaml/Makefile
@@ -2,7 +2,7 @@ STEPS = step0_repl.ml step1_read_print.ml step2_eval.ml step3_env.ml \
step4_if_fn_do.ml step5_tco.ml step6_file.ml step7_quote.ml \
step8_macros.ml step9_try.ml stepA_interop.ml
MODULES = types.ml reader.ml printer.ml env.ml core.ml
-LIBS = str.cmxa
+LIBS = str.cmxa unix.cmxa
MAL_LIB = mal_lib.cmxa
STEP_BINS = $(STEPS:%.ml=%)
diff --git a/ocaml/core.ml b/ocaml/core.ml
index 6d7b014..20f68b6 100644
--- a/ocaml/core.ml
+++ b/ocaml/core.ml
@@ -197,4 +197,7 @@ let init env = begin
Env.set env (Types.symbol "swap!")
(Types.fn (function T.Atom x :: T.Fn { T.value = f } :: args
-> let v = f (!x :: args) in x := v; v | _ -> T.Nil));
+
+ Env.set env (Types.symbol "time-ms")
+ (Types.fn (function _ -> T.Int (truncate (1000.0 *. Unix.gettimeofday ()))));
end