Пример #1
0
        public override IExpression?Simplify()
        {
            var newLeft  = Left?.Simplify();
            var newRight = Right?.Simplify();

            var leftConst  = newLeft as ConstantExpression;
            var rightConst = newRight as ConstantExpression;

            if (leftConst != null && rightConst != null)
            {
                // two constants
                return(new ConstantExpression(BooleanFunctions.And(leftConst.Value, rightConst.Value)));
            }
            if (leftConst?.Value == 0 ||
                rightConst?.Value == 0)
            {
                return(new ConstantExpression(0.0));
            }

            return(new AndExpression(newLeft, newRight));
        }
Пример #2
0
 protected override Number Evaluate(Number number1, Number number2)
 {
     return(BooleanFunctions.And(number1, number2));
 }