コード例 #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));
        }
コード例 #2
0
ファイル: coperator.cs プロジェクト: rubikscraft/LambdaLang
        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);
        }