예제 #1
0
        static public object Eval(object form)
        {
            Cons pair = form as Cons;

            if (pair != null)
            {
                object op       = pair.Car;
                object operands = pair.Cdr;
                object sym      = op as Symbol;
                if (sym != null)
                {
                    return(CL.Apply(CL.SymbolFunction(sym), Evlis(operands)));
                }
                else
                {
                    throw new NotImplementedException("Operator not a symbol");
                }
            }
            else
            {
                Symbol identifier = form as Symbol;
                if (identifier != null)
                {
                    return(CL.SymbolValue(form));
                }
                else
                {
                    string literal = form as String;
                    if (literal != null)
                    {
                        return(literal);
                    }
                    else
                    {
                        throw new NotImplementedException("No lambda functions yet");
                    }
                }
            }
        }