wl

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

commit 1c4cdc19b99423e1415a1e4a2c42b1d3401e0c00
parent b79439d2caac12c98368af6949eb5387234c1351
Author: tomas <tomas@logand.com>
Date:   Sun, 25 Oct 2009 12:01:55 +0100

run eval work now fully, undo redo fixed - exclude list

Diffstat:
Mwl.java | 40+++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/wl.java b/wl.java @@ -546,17 +546,15 @@ class wl implements Runnable { if(null != Z) Z.val(mkObj(F)); else Sd.put(Nm, mkIsym(Nm, mkObj(F))); } + boolean member(Any X, Any L) { + for(; L.isCons(); L = L.cdr()) + if(X == L.car()) return true; + return false; + } Any undo(int n, Any L) { Any Z = NIL; Any E = Env.val(); - // if(0 < n) { - // System.out.println(n); - // dbg("E+", E); - // dbg("*Stk", Stk.val()); - // } for(int i = 0; i < n; i++) { - // System.out.println(i); - // dbg("Z", Z); while(E.isCons() && T != E.car()) { Any C = E.car(); // flip @@ -566,9 +564,12 @@ class wl implements Runnable { Z = F; // swap Any K = C.car(); - Any V = K.val(); - K.val(C.cdr()); - C.cdr(V); + if(member(K, L)) C.car(mkCons(K, NIL)); // (K . old) -> ((K) . old) + else { // (K . old) -> (K . cur) + set old + Any V = K.val(); + K.val(C.cdr()); + C.cdr(V); + } } if(T == E.car()) { // flip @@ -578,8 +579,6 @@ class wl implements Runnable { Z = F; } } - // if(0 < n) dbg("E-", E); - //dbg("Z", Z); Env.val(E); return Z; } @@ -591,9 +590,12 @@ class wl implements Runnable { if(C.isCons()) { // swap Any K = C.car(); - Any V = K.val(); - K.val(C.cdr()); - C.cdr(V); + if(K.isCons()) C.car(K.car()); // ((K) . old) -> (E . old) + else { // (K . cur) -> (K . old) + set cur + Any V = K.val(); + K.val(C.cdr()); + C.cdr(V); + } } // flip Any F = E; @@ -654,8 +656,8 @@ class wl implements Runnable { Any L = NIL; if(I.cdr().isCons()) { I = I.cdr(); - n = ((BigInteger) I.car().obj()).intValue(); - if(I.cdr().isCons()) L = I.cdr(); + n = ((BigInteger) eval(I.car()).obj()).intValue(); + L = eval(I.cdr().car()); } return xrun(P, n, L); }}); @@ -666,8 +668,8 @@ class wl implements Runnable { Any L = NIL; if(I.cdr().isCons()) { I = I.cdr(); - n = ((BigInteger) I.car().obj()).intValue(); - if(I.cdr().isCons()) L = I.cdr(); + n = ((BigInteger) eval(I.car()).obj()).intValue(); + L = eval(I.cdr().car()); } return eval(X, n, L); }});