public void calculate()
        {
            if (Operands == null)
            {
                Result = 0;
                return;
            }

            switch (Operation)
            {
            case CalculatorOperations.Add:
                Result = Operands.Aggregate((f1, f2) => f1 + f2);
                break;

            case CalculatorOperations.Sub:
                Result = Operands.Aggregate((f1, f2) => f1 - f2);
                break;

            case CalculatorOperations.Mul:
                Result = Operands.Aggregate((f1, f2) => f1 * f2);
                break;

            case CalculatorOperations.Div:
                Result = Operands.Aggregate((f1, f2) => f1 / f2);
                break;
            }
        }
Example #2
0
            public override StringTemplate GenExpr(CodeGenerator generator, TemplateGroup templates, DFA dfa)
            {
                StringTemplate result =
                    Operands.Aggregate(default(StringTemplate),
                                       (template, operand) =>
                {
                    if (template == null)
                    {
                        return(operand.GenExpr(generator, templates, dfa));
                    }

                    StringTemplate eST = null;
                    if (templates != null)
                    {
                        eST = templates.GetInstanceOf("andPredicates");
                    }
                    else
                    {
                        eST = new StringTemplate("(<left>&&<right>)");
                    }

                    eST.SetAttribute("left", template);
                    eST.SetAttribute("right", operand.GenExpr(generator, templates, dfa));
                    return(eST);
                });

                return(result);
            }
Example #3
0
 public double?Execute()
 {
     Result = Operands.Aggregate((a, b) => a * b);
     return(Result);
 }
Example #4
0
 protected override int CalculateHashCode()
 {
     return(Operands.Aggregate(0, (x, y) => x ^ ~y.GetHashCode()));
 }
Example #5
0
 public double?Execute()
 {
     Result = Operands.Aggregate((n, p) => Math.Pow(n, p));
     return(Result);
 }
 public double?Execute()
 {
     Result = Operands.Aggregate((a, b) => Math.Pow(a, b));
     return(null);
 }
 public double?Execute()
 {
     Result = Operands.Aggregate((a, b) => a - b);
     return(null);
 }
Example #8
0
 public double?Execute()
 {
     Result = Operands.Aggregate((lhs, rhs) => Math.Pow(lhs, rhs));
     return(Result);
 }
Example #9
0
 public double?Execute()
 {
     Result = Operands.Aggregate((lhs, rhs) => lhs * rhs);
     return(Result);
 }