wl

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

commit 3ccab2c059bebf5c26480765298385d3251adf17
parent 51119810287735eed44e00862f44abd87912d718
Author: tomas <tomas@logand.com>
Date:   Sat, 10 Oct 2009 22:30:10 +0200

tidy up

Diffstat:
Mwl.java | 56++++++++++++--------------------------------------------
1 file changed, 12 insertions(+), 44 deletions(-)

diff --git a/wl.java b/wl.java @@ -331,33 +331,21 @@ class wl implements Runnable { int n = 0; if(Fa.isIsym()) { // (@ . P) | (L . P) | (NIL . P) if(NIL != Fa) { - if(At == Fa) { - bind(Args, mkCons(NIL, mapcarEval(A))); - n++; - } else { - bind(Fa, A); - n++; - } + if(At == Fa) {bind(Args, mkCons(NIL, mapcarEval(A))); n++;} + else {bind(Fa, A); n++;} } } else if(Fa.isCons()) { // ((L ...) . P) while(Fa.isCons()) { - Any X = Fa.car(); - Fa = Fa.cdr(); - bind(X, eval(A.car())); + bind(Fa.car(), eval(A.car())); n++; + Fa = Fa.cdr(); A = A.cdr(); } if(NIL != Fa) { - if(At == Fa) { // ((L . @) . P) - bind(Args, mkCons(NIL, mapcarEval(A))); - n++; - } else { // ((L . M) . P) - bind(Fa, A); - n++; - } + if(At == Fa) {bind(Args, mkCons(NIL, mapcarEval(A))); n++;} + else {bind(Fa, A); n++;} } } else err(Fa, "Don't know how to bind"); - Z = xrun(Fb); unbind(n); unframe(); @@ -404,36 +392,17 @@ class wl implements Runnable { } return Z; } - void bind(Any S, Any V) { - dbg(" 1", Env.val()); - Env.val(mkCons(mkCons(S, S.val()), Env.val())); - S.val(V); - dbg(" 2", Env.val()); - } - void bind(Any S) { - dbg(" 1", Env.val()); - Env.val(mkCons(mkCons(S, S.val()), Env.val())); - dbg(" 2", Env.val()); - } + void frame() {Env.val(mkCons(T, Env.val()));} + void bind(Any S) {Env.val(mkCons(mkCons(S, S.val()), Env.val()));} + void bind(Any S, Any V) {bind(S); S.val(V);} void unbind() { - dbg(" 3", Env.val()); Any E = Env.val(); Any X = E.car(); X.car().val(X.cdr()); Env.val(E.cdr()); - dbg(" 4", Env.val()); } void unbind(int n) {for(int i = 0; i < n; i++) unbind();} - void frame() { - dbg("1", Env.val()); - Env.val(mkCons(T, Env.val())); - dbg("2", Env.val()); - } - void unframe() { - dbg("3", Env.val()); - Env.val(Env.val().cdr()); - dbg("4", Env.val()); - } + void unframe() {Env.val(Env.val().cdr());} void fn(String Nm, Fn F) { Any Z = Sd.get(Nm); @@ -727,10 +696,9 @@ class wl implements Runnable { if(L.isCons()) { // (use (K ...) . P) int n = 0; while(L.isCons()) { - Any K = L.car(); - L = L.cdr(); - bind(K); + bind(L.car()); n++; + L = L.cdr(); } Z = xrun(I.cdr()); unbind(n);