aboutsummaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-17 21:49:07 -0500
committerJoel Martin <github@martintribe.org>2014-04-17 21:49:07 -0500
commitdb4c329aff4621e05b92a55be4f18173f5a4f655 (patch)
tree92baaa6d88246e509cfd6a7d03d8fab997e0b935 /php
parent8cb5cda46cf3aef847ae3926dc53a5e5f87fe261 (diff)
downloadmal-db4c329aff4621e05b92a55be4f18173f5a4f655.tar.gz
mal-db4c329aff4621e05b92a55be4f18173f5a4f655.zip
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
Diffstat (limited to 'php')
-rw-r--r--php/core.php7
-rw-r--r--php/stepA_more.php1
2 files changed, 8 insertions, 0 deletions
diff --git a/php/core.php b/php/core.php
index 39a22ac..4cb4667 100644
--- a/php/core.php
+++ b/php/core.php
@@ -37,6 +37,12 @@ function println() {
}
+// Number functions
+function time_ms() {
+ return intval(microtime(1) * 1000);
+}
+
+
// Hash Map functions
function assoc($src_hm) {
$args = func_get_args();
@@ -188,6 +194,7 @@ $core_ns = array(
'-'=> function ($a, $b) { return intval($a - $b,10); },
'*'=> function ($a, $b) { return intval($a * $b,10); },
'/'=> function ($a, $b) { return intval($a / $b,10); },
+ 'time-ms'=>function () { return time_ms(); },
'list'=> function () { return call_user_func_array('_list', func_get_args()); },
'list?'=> function ($a) { return _list_Q($a); },
diff --git a/php/stepA_more.php b/php/stepA_more.php
index c599986..2eae095 100644
--- a/php/stepA_more.php
+++ b/php/stepA_more.php
@@ -177,6 +177,7 @@ $repl_env->set('eval', _function(function($ast) {
}));
// core.mal: defined using the language itself
+rep("(def! *host-language* \"php\")");
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)))))))");