public Empty Visit(DekiScriptSequence expr, StringBuilder state)
        {
            switch (expr.List.Length)
            {
            case 0:
                state.Append("nil");
                break;

            case 1:
                expr.List[0].VisitWith(this, state);
                break;

            default:
                state.Append('(');
                bool first = true;
                foreach (var expression in expr.List)
                {
                    if (!first)
                    {
                        state.Append("; ");
                    }
                    first = false;
                    expression.VisitWith(this, state);
                }
                state.Append(')');
                break;
            }
            return(Empty.Value);
        }
 private static void Flatten(ICollection <DekiScriptExpression> accumulator, IEnumerable <DekiScriptExpression> list)
 {
     foreach (var expression in list)
     {
         if (expression is DekiScriptNil)
         {
             // ignore expression
         }
         else if (expression is DekiScriptSequence)
         {
             DekiScriptSequence expr = (DekiScriptSequence)expression;
             Flatten(accumulator, expr.List);
         }
         else
         {
             accumulator.Add(expression);
         }
     }
 }