예제 #1
0
        public override string DisplayObject()
        {
            StringBuilder repr = new StringBuilder("(");

            repr.Append(DisplayValue());
            CTObject tail = cdr;

            while (true)
            {
                if (tail.GetType() == typeof(CTPair))
                {
                    CTPair rest = (CTPair)tail;
                    repr.Append(" ").Append(rest.DisplayValue());
                    tail = rest.cdr;
                }
                else
                {
                    if (tail.GetType() != typeof(CTEmptyList))
                    {
                        repr.Append(" . ").Append(tail.DisplayObject());
                    }
                    break;
                }
            }

            repr.Append(")");

            return(repr.ToString());
        }
예제 #2
0
 private static void AssertNumber(string functionName, CTObject arg)
 {
     if (arg.GetType() != typeof(CTNumber))
     {
         throw new TypeError(functionName, CTNumber.TypeName, arg.DisplayType());
     }
 }
예제 #3
0
 protected override bool IsEqualTo(CTObject obj)
 {
     if (obj.GetType() == typeof(CTPair))
     {
         CTPair other = (CTPair)obj;
         return(other.car.Equals(car) && other.cdr.Equals(cdr));
     }
     else
     {
         return(false);
     }
 }
예제 #4
0
 protected override bool IsEqualTo(CTObject obj)
 {
     return(obj.GetType() == typeof(CTSymbol) && ((CTSymbol)obj).name.Equals(name));
 }
예제 #5
0
 protected override bool IsEqualTo(CTObject obj)
 {
     return(obj.GetType() == typeof(CTString) && ((CTString)obj).value.Equals(value));
 }
예제 #6
0
 protected override bool IsEqualTo(CTObject obj)
 {
     return(obj.GetType() == typeof(CTEmptyList));
 }
예제 #7
0
 protected override bool IsEqualTo(CTObject obj)
 {
     return(obj.GetType() == typeof(CTNumber) && ((CTNumber)obj).value == value);
 }
예제 #8
0
 protected override bool IsEqualTo(CTObject obj)
 {
     return(obj.GetType() == typeof(CTUndefined));
 }
예제 #9
0
 public static CTObject IsNull(CTObject v)
 {
     return(Constants.ToCTBool(v.GetType() == typeof(CTEmptyList)));
 }