Exemplo n.º 1
0
        public override Result Apply(Scope scope, Result argument)
        {
            int number = int.Parse(argument.Get().ToString());

            Solvable expresion = new Variable("x");

            for (int i = 0; i < number; i++)
            {
                expresion = new COperator(new Variable("f"), expresion);
            }

            expresion = new Abstraction("x", expresion);
            expresion = new Abstraction("f", expresion);

            return(expresion.Solve(scope));
        }
Exemplo n.º 2
0
        public override Result Apply(Scope scope, Result argument)
        {
            if (argument.GetType() != typeof(FunctionResult))
            {
                return(new ConstantResult(0));
            }

            Result helperResult = helperAbstraction.Solve(scope);

            Result xFunc = ((FunctionResult)argument).Apply(helperResult);

            if (xFunc.GetType() != typeof(FunctionResult))
            {
                return(new ConstantResult(0));
            }

            Result solved = ((FunctionResult)xFunc).Apply(new ConstantResult(0));

            return(solved);
        }