From f5fc0c98ee9c140077469146bbc9d8a77fdb02f3 Mon Sep 17 00:00:00 2001 From: Chouser Date: Fri, 30 Jan 2015 12:38:32 -0500 Subject: OCaml: Add time-ms --- ocaml/Makefile | 2 +- ocaml/core.ml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3