public override bool Equals(object obj) { if (obj.GetType() == typeof(RacketPair)) { RacketPair other = (RacketPair)obj; if (this.isNull() && other.isNull()) { return(true); } //one of us is null the other is not if (this.isNull() || other.isNull()) { return(false); } return(this.value.Equals(other.car()) && this.rest.Equals(other.cdr())); } return(base.Equals(obj)); }
public static ObjBox Reverse(RacketPair list) { bool restNull = false; if (list.isNull()) { return(new ObjBox(list, typeof(RacketPair))); } RacketPair accu = new RacketPair(list.car(), new ObjBox(new RacketPair(), typeof(RacketPair))); list = (RacketPair)list.cdr().getObj(); while (!list.isNull()) { accu = new RacketPair(list.car(), new ObjBox(accu, typeof(RacketPair))); list = (RacketPair)list.cdr().getObj(); } return(new ObjBox(accu, typeof(RacketPair))); }
public static ObjBox Reverse(RacketPair list) { bool restNull = false; if (list.isNull()) return new ObjBox(list, typeof(RacketPair)); RacketPair accu = new RacketPair(list.car(), new ObjBox(new RacketPair(), typeof(RacketPair))); list = (RacketPair)list.cdr().getObj(); while (!list.isNull()) { accu = new RacketPair(list.car(), new ObjBox(accu, typeof(RacketPair))); list = (RacketPair)list.cdr().getObj(); } return new ObjBox(accu, typeof(RacketPair)); }