Example #1
0
        private void DefineProcedure(Environment environment)
        {
            var expressions = (DefinedName as Application).Expressions.ToList();
            var procName    = (expressions[0] as Variable).Name;
            var isVariadic  = expressions.Count > 2 && expressions[expressions.Count - 2] is SpecialToken && (expressions[expressions.Count - 2] as SpecialToken).Token == ".";

            if (isVariadic)
            {
                expressions.RemoveAt(expressions.Count - 2);
            }
            var proc    = new UserDefinedProcedure(DefinedValue, isVariadic, expressions.Skip(1).Select(v => (v as Variable).Name).ToList());
            var closure = new Closure(environment, proc);

            environment[procName] = closure;
        }
Example #2
0
        public override Value Eval(Environment environment)
        {
            var proc = new UserDefinedProcedure(DefinedValue, false, FormalArguments.Select(v => v.Name).ToList());

            return(new Closure(environment, proc));
        }