Beispiel #1
0
        public virtual Result Apply(Scope scope, Result argument)
        {
            var subScope = scope.GetChild();

            if (argumentName is string)
            {
                subScope.Store(argumentName, argument);
            }

            return(expression.Solve(subScope));
        }
Beispiel #2
0
        public override Result Solve(Scope scope)
        {
            var functionResult = func.Solve(scope);

            if (functionResult.GetType() != typeof(FunctionResult))
            {
                throw new LambdaException(func + " is not a function");
            }

            Result result;

            if (argument is Solvable)
            {
                var ASolved = argument.Solve(scope);
                result = ((FunctionResult)functionResult).Apply(ASolved);
            }
            else
            {
                result = ((FunctionResult)functionResult).Apply();
            }

            return(result);
        }