wl

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

commit 8c579a5c63b1a9116835b31288f499cde9204115
parent c835b1772fc487087d5f5f6c45b251dbe1174f30
Author: tomas <tomas@logand.com>
Date:   Wed,  7 Oct 2009 21:43:20 +0200

set|con|obj replaced by car|cdr|cxr setters

Diffstat:
Mwl.java | 70+++++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/wl.java b/wl.java @@ -62,9 +62,9 @@ class wl implements Runnable { public Any car(); public Any cdr(); public Object cxr(); - public Any set(Any a); - public Any con(Any d); - public Object obj(Object x); + public Any car(Any a); + public Any cdr(Any d); + public Object cxr(Object x); public boolean isCons(); public boolean isSym(); public boolean isIsym(); @@ -81,9 +81,9 @@ class wl implements Runnable { public Any car() {return car;} public Any cdr() {return cdr;} public Object cxr() {err("No Cons.cxr"); return null;} - public Any set(Any a) {car = a; return car;} - public Any con(Any d) {cdr = d; return cdr;} - public Object obj(Object x) {err("No Cons.obj"); return null;} + public Any car(Any a) {car = a; return car;} + public Any cdr(Any d) {cdr = d; return cdr;} + public Object cxr(Object x) {err("No Cons.obj"); return null;} public boolean isCons() {return true;}; public boolean isSym() {return false;}; public boolean isIsym() {return false;}; @@ -102,9 +102,9 @@ class wl implements Runnable { public Any car() {return car;} public Any cdr() {return cdr;} public Object cxr() {err("No Isym.cxr"); return null;} - public Any set(Any a) {car = a; return car;} - public Any con(Any d) {cdr = d; return cdr;} - public Object obj(Object x) {err("No Isym.obj"); return null;} + public Any car(Any a) {car = a; return car;} + public Any cdr(Any d) {cdr = d; return cdr;} + public Object cxr(Object x) {err("No Isym.obj"); return null;} public boolean isCons() {return false;}; public boolean isSym() {return true;}; public boolean isIsym() {return true;}; @@ -121,9 +121,9 @@ class wl implements Runnable { public Any car() {err("No Obj.car"); return null;} public Any cdr() {err("No Obj.cdr"); return null;} public Object cxr() {return cxr;} - public Any set(Any a) {err("No Obj.set"); return null;} - public Any con(Any d) {err("No Obj.con"); return null;} - public Object obj(Object x) {cxr = x; return cxr;} + public Any car(Any a) {err("No Obj.set"); return null;} + public Any cdr(Any d) {err("No Obj.con"); return null;} + public Object cxr(Object x) {cxr = x; return cxr;} public boolean isCons() {return false;}; public boolean isSym() {return false;}; public boolean isIsym() {return false;}; @@ -144,9 +144,9 @@ class wl implements Runnable { final static Any T = mkIsym("T", NIL, null); static { - NIL.set(NIL); - NIL.con(NIL); - T.con(T); + NIL.car(NIL); + NIL.cdr(NIL); + T.cdr(T); } // reader @@ -238,13 +238,13 @@ class wl implements Runnable { boolean D = false; while(null != (X = read1(false)) && Rp != X) { if(Dot != X) { - Z.con(D ? X : mkCons(X, NIL)); + Z.cdr(D ? X : mkCons(X, NIL)); if(Z.cdr().isCons()) Z = Z.cdr(); } D = Dot == X; } if(null == X) err("Reader underflow"); - if(D) Z.con(A.cdr()); + if(D) Z.cdr(A.cdr()); return A.cdr(); } public void run() { @@ -306,7 +306,7 @@ class wl implements Runnable { Any A = mkCons(NIL, NIL); Any Z = A; while(E.isCons()) { - Z.con(mkCons(eval(E.car()), NIL)); + Z.cdr(mkCons(eval(E.car()), NIL)); Z = Z.cdr(); E = E.cdr(); } @@ -318,10 +318,10 @@ class wl implements Runnable { if(NIL != Fa) { if(At == Fa) { O = mkCons(Args.cdr(), NIL); - Args.con(mkCons(NIL, mapcarEval(A))); + Args.cdr(mkCons(NIL, mapcarEval(A))); } else { O = mkCons(Fa.cdr(), NIL); - Fa.con(A); + Fa.cdr(A); } } } else if(Fa.isCons()) { @@ -331,19 +331,19 @@ class wl implements Runnable { Any X = Fa.car(); Fa = Fa.cdr(); if(!X.isIsym()) err(X, "Isym expected in saveV"); - Z.con(mkCons(X.cdr(), NIL)); + Z.cdr(mkCons(X.cdr(), NIL)); Z = Z.cdr(); - X.con(eval(A.car())); + X.cdr(eval(A.car())); A = A.cdr(); } if(NIL != Fa) { if(!Fa.isIsym()) err(Fa, "Isym expected in saveV"); if(At == Fa) { - Z.con(mkCons(Args.cdr(), NIL)); - Args.con(mkCons(NIL, mapcarEval(A))); + Z.cdr(mkCons(Args.cdr(), NIL)); + Args.cdr(mkCons(NIL, mapcarEval(A))); } else { - Z.con(mkCons(Fa.cdr(), NIL)); - Fa.con(A); + Z.cdr(mkCons(Fa.cdr(), NIL)); + Fa.cdr(A); } } O = B.cdr(); @@ -353,21 +353,21 @@ class wl implements Runnable { void restoreV(Any Fa, Any O) { if(Fa.isIsym()) { if(NIL != Fa) { - if(At == Fa) Args.con(O.car()); - else Fa.con(O.car()); + if(At == Fa) Args.cdr(O.car()); + else Fa.cdr(O.car()); } } else if(Fa.isCons()) { while(Fa.isCons()) { Any X = Fa.car(); Fa = Fa.cdr(); if(!X.isIsym()) err(X, "Isym expected in restoreV"); - X.con(O.car()); + X.cdr(O.car()); O = O.cdr(); } if(NIL != Fa) { if(!Fa.isIsym()) err(Fa, "Isym expected in saveV"); - if(At == Fa) Args.con(O.car()); - else Fa.con(O.car()); + if(At == Fa) Args.cdr(O.car()); + else Fa.cdr(O.car()); } } else err(Fa, "Don't know how to restoreV"); } @@ -404,7 +404,7 @@ class wl implements Runnable { void fn(String Nm, Fn F) { Any Z = Sd.get(Nm); - if(null != Z) Z.con(mkObj(F)); + if(null != Z) Z.cdr(mkObj(F)); else Sd.put(Nm, mkIsym(Nm, NIL, mkObj(F))); } @@ -579,7 +579,7 @@ class wl implements Runnable { if(!N.isSym()) err(E, "Symbol expected"); if(!Sd.containsKey(N.nm())) err(E, "Symbol not interned"); Any V = eval(X.cdr().car()); - Sd.get(N.nm()).con(V); + Sd.get(N.nm()).cdr(V); return N; }}); fn("val", new Fn() {public Any fn(Any E) { @@ -707,9 +707,9 @@ class wl implements Runnable { ByteArrayOutputStream B = new ByteArrayOutputStream(); PrintStream S = new PrintStream(B); Any O = Out.cdr(); - Out.con(mkObj(S)); + Out.cdr(mkObj(S)); print(E); - Out.con(O); + Out.cdr(O); String Z = null; try { Z = B.toString(Enc);