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})"); } }
public static bool IsList(ISexpr sexpr) { return(sexpr.IsAtom && sexpr.AtomKind == SexprAtom.KindCode.Null || sexpr.IsPair && IsList(sexpr.Right)); }
public static SexprPair Pair(ISexpr left, ISexpr right) { return(new SexprPair(left, right)); }
public SexprPair(ISexpr left, ISexpr right) { Left = left; Right = right; }