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;
            }
        }
            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);
            }
Beispiel #3
0
 public double?Execute()
 {
     Result = Operands.Aggregate((a, b) => a * b);
     return(Result);
 }
 protected override int CalculateHashCode()
 {
     return(Operands.Aggregate(0, (x, y) => x ^ ~y.GetHashCode()));
 }
Beispiel #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);
 }
Beispiel #8
0
 public double?Execute()
 {
     Result = Operands.Aggregate((lhs, rhs) => Math.Pow(lhs, rhs));
     return(Result);
 }
Beispiel #9
0
 public double?Execute()
 {
     Result = Operands.Aggregate((lhs, rhs) => lhs * rhs);
     return(Result);
 }