예제 #1
0
 public override string ToString()
 {
     if (Sexpr.IsList(this))
     {
         ISexpr items   = this;
         var    builder = new StringBuilder();
         builder.Append("( ");
         while (items.IsPair)
         {
             var item = items.Left;
             items = items.Right;
             builder.Append(item).Append(" ");
         }
         builder.Append(")");
         return(builder.ToString());
     }
     else
     {
         return($"({Left} . {Right})");
     }
 }
예제 #2
0
 public static bool IsList(ISexpr sexpr)
 {
     return(sexpr.IsAtom && sexpr.AtomKind == SexprAtom.KindCode.Null ||
            sexpr.IsPair && IsList(sexpr.Right));
 }
예제 #3
0
 public static SexprPair Pair(ISexpr left, ISexpr right)
 {
     return(new SexprPair(left, right));
 }
예제 #4
0
 public SexprPair(ISexpr left, ISexpr right)
 {
     Left  = left;
     Right = right;
 }