wl

Unnamed repository; edit this file 'description' to name the repository.
git clone https://logand.com/git/wl.git/
Log | Files | Refs | LICENSE

commit 101bc47198243e7c91907426102eb4a141275ac8
parent 784ec09a55ec28a69b5f88e809b451d2b0c62804
Author: tomas <tomas@logand.com>
Date:   Fri, 30 Oct 2009 20:11:26 +0100

bind, jeq, sys and println prinl fix

Diffstat:
Mjava.wl | 12++++++++----
Mwl.java | 32++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/java.wl b/java.wl @@ -261,12 +261,12 @@ (de last (L) (foldl1 '((X Y) Y) L)) (de println @ - (pass print) - (prin "^J") ) + (prog1 (pass print) + (prin "^J") ) ) (de prinl @ - (pass prin) - (prin "^J") ) + (prog1 (pass prin) + (prin "^J") ) ) (de * @ (when (args) (foldl1 '((X Y) (X 'multiply Y)) (rest)))) (de / @ (when (args) (foldl1 '((X Y) (X 'divide Y)) (rest)))) @@ -469,3 +469,7 @@ (if (num? X) (1- X) (set X (- (val X) (or (next) 1))) ) ) + +(de sys (K . @) (`(jclass 'java.lang.System) 'getenv K)) + +#(de exec () (`((jclass 'java.lang.Runtime) 'getRuntime) 'gc)) diff --git a/wl.java b/wl.java @@ -973,6 +973,29 @@ class wl implements Runnable { } else err(E, "Don't know how to job"); return Z; }}); + fn("bind", new Fn() {public Any fn(Any E) { + Any Z = NIL; + Any I = E.cdr(); + Any L = eval(I.car()); + if(L.isCons()) { // (let (K 'V ...) . P) + int n = 0; + while(L.isCons()) { + Any C = L.car(); + L = L.cdr(); + if(C.isCons()) bind(C.car(), C.cdr()); + else if(C.isSym()) bind(C); + else err(E, "Don't know how to bind"); + n++; + } + try {Z = xrun(I.cdr());} + finally {unbind(n);} + } else if(L.isIsym()) { // (bind L . P) + bind(L); + try {Z = xrun(I.cdr());} + finally {unbind();} + } else err(E, "Don't know how to bind"); + return Z; + }}); fn("up", new Fn() {public Any fn(Any E) { // (up [cnt] sym ['val]) Any Z; Any I = E.cdr(); @@ -1119,6 +1142,15 @@ class wl implements Runnable { Z = mkObj(r); return Z; }}); + fn("jeq", new Fn() {public Any fn(Any E) { + Any I = E.cdr(); + if(I.isCons()) { + Any X = eval(I.car()); + for(I = I.cdr(); I.isCons(); I = I.cdr()) + if(X.obj() != eval(I.car()).obj()) return NIL; + } + return T; + }}); fn("wait", new Fn() {public Any fn(Any E) { // wait ['cnt] . prg Any Z = NIL; // TODO poll from Que with timeout cnt unless run(prg)