Revision: 1.1 - (view) (download) (as text)
1 : | ktanaka | 1.1 | // |
2 : | // | ||
3 : | // | ||
4 : | |||
5 : | final public class Cons extends LispObject{ | ||
6 : | LispObject carContent,cdrContent; | ||
7 : | Cons(LispObject carContent, LispObject cdrContent){ | ||
8 : | this.carContent=carContent; | ||
9 : | this.cdrContent=cdrContent; | ||
10 : | } | ||
11 : | public int getType(){ return CONS; } | ||
12 : | public LispObject car(){ return carContent; } | ||
13 : | public LispObject cdr(){ return cdrContent; } | ||
14 : | public void setCar(LispObject a){ carContent=a; } | ||
15 : | public void setCdr(LispObject a){ cdrContent=a; } | ||
16 : | public String toString(){ | ||
17 : | String ret="("; | ||
18 : | LispObject l=this; | ||
19 : | while(true){ | ||
20 : | ret+=((Cons)l).car().toString(); | ||
21 : | l=((Cons)l).cdr(); | ||
22 : | if(l.getType()!=CONS) break; | ||
23 : | ret+=" "; | ||
24 : | } | ||
25 : | if(l == Symbol.nil) return ret+")"; | ||
26 : | else return ret+" . "+l.toString()+")"; | ||
27 : | } | ||
28 : | } |
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |