Пример #1
0
        public static List <Item> Eval(BoolExpr expr)
        {
            if (expr.IsLeaf())
            {
                return(expr.Lit);
            }

            if (expr.Op == BoolExpr.BOP.OR)
            {
                return(Eval(expr.Left).Union(Eval(expr.Right)).ToList());
            }

            if (expr.Op == BoolExpr.BOP.AND)
            {
                return(Eval(expr.Left).Intersect(Eval(expr.Right)).ToList());
            }
            throw new ArgumentException();
        }
 public static BoolExpr CreateOr(BoolExpr left, BoolExpr right)
 {
     return(new BoolExpr(BOP.OR, left, right));
 }
        //
        //  public factory
        //

        public static BoolExpr CreateAnd(BoolExpr left, BoolExpr right)
        {
            return(new BoolExpr(BOP.AND, left, right));
        }