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 --- ps/core.ps | 3 +-- ps/env.ps | 2 -- ps/printer.ps | 2 -- ps/reader.ps | 2 -- ps/step7_quote.ps | 2 +- ps/step8_macros.ps | 2 +- ps/step9_interop.ps | 2 +- ps/stepA_more.ps | 3 ++- ps/types.ps | 2 -- 9 files changed, 6 insertions(+), 14 deletions(-) (limited to 'ps') diff --git a/ps/core.ps b/ps/core.ps index f9397fa..191e5c3 100644 --- a/ps/core.ps +++ b/ps/core.ps @@ -1,5 +1,3 @@ -(in core.ps\n) print - % requires types.ps % Errors/Exceptions @@ -239,6 +237,7 @@ end } def (-) { dup 0 _nth exch 1 _nth sub } (*) { dup 0 _nth exch 1 _nth mul } (/) { dup 0 _nth exch 1 _nth idiv } + (time-ms) { pop realtime } (list) { /data get _list_from_array } (list?) { 0 _nth _list? } diff --git a/ps/env.ps b/ps/env.ps index 4eb3484..f6d5b88 100644 --- a/ps/env.ps +++ b/ps/env.ps @@ -1,5 +1,3 @@ -(in env.ps\n) print - % outer binds exprs -> env_new -> new_env /env_new { 3 dict begin %(in env_new\n) print diff --git a/ps/printer.ps b/ps/printer.ps index de91d80..3062e2d 100644 --- a/ps/printer.ps +++ b/ps/printer.ps @@ -1,5 +1,3 @@ -(in printer.ps\n) print - % requires types.ps to be included first % ast print_readably -> _pr_str -> string diff --git a/ps/reader.ps b/ps/reader.ps index 188a121..f1f63f6 100644 --- a/ps/reader.ps +++ b/ps/reader.ps @@ -1,5 +1,3 @@ -(in reader\n) print - % requires types.ps to be included first /token_delim (;,"` \n{}\(\)[]) def diff --git a/ps/step7_quote.ps b/ps/step7_quote.ps index f335683..93bf464 100644 --- a/ps/step7_quote.ps +++ b/ps/step7_quote.ps @@ -17,7 +17,7 @@ % is_pair?: ast -> is_pair? -> bool % return true if non-empty list, otherwise false /is_pair? { - dup _list? { _count 0 gt }{ pop false } ifelse + dup _sequential? { _count 0 gt }{ pop false } ifelse } def % ast -> quasiquote -> new_ast diff --git a/ps/step8_macros.ps b/ps/step8_macros.ps index 87fafb1..814b62b 100644 --- a/ps/step8_macros.ps +++ b/ps/step8_macros.ps @@ -17,7 +17,7 @@ % is_pair?: ast -> is_pair? -> bool % return true if non-empty list, otherwise false /is_pair? { - dup _list? { _count 0 gt }{ pop false } ifelse + dup _sequential? { _count 0 gt }{ pop false } ifelse } def % ast -> quasiquote -> new_ast diff --git a/ps/step9_interop.ps b/ps/step9_interop.ps index fbf51a5..e8d837f 100644 --- a/ps/step9_interop.ps +++ b/ps/step9_interop.ps @@ -17,7 +17,7 @@ % is_pair?: ast -> is_pair? -> bool % return true if non-empty list, otherwise false /is_pair? { - dup _list? { _count 0 gt }{ pop false } ifelse + dup _sequential? { _count 0 gt }{ pop false } ifelse } def % ast -> quasiquote -> new_ast diff --git a/ps/stepA_more.ps b/ps/stepA_more.ps index 1720b94..73403b0 100644 --- a/ps/stepA_more.ps +++ b/ps/stepA_more.ps @@ -17,7 +17,7 @@ % is_pair?: ast -> is_pair? -> bool % return true if non-empty list, otherwise false /is_pair? { - dup _list? { _count 0 gt }{ pop false } ifelse + dup _sequential? { _count 0 gt }{ pop false } ifelse } def % ast -> quasiquote -> new_ast @@ -252,6 +252,7 @@ core_ns { _ref } forall (eval) { 0 _nth repl_env EVAL } _ref % core.mal: defined using the language itself +(\(def! *host-language* "postscript"\)) RE pop (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop (\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop (\(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\)\)\)\)\)\)\)) RE pop diff --git a/ps/types.ps b/ps/types.ps index 2b26582..82be9c2 100644 --- a/ps/types.ps +++ b/ps/types.ps @@ -1,5 +1,3 @@ -(in types.ps\n) print - % General functions % concatenate: concatenate two strings or two arrays -- cgit v1.2.3