pub fn explicit_coefficients(self) -> Expression {
        match self {
            Expression::Variadic(Operator::Add, exprs) => {
                let exprs = exprs
                    .into_iter()
                    .map(Expression::explicit_coefficients)
                    .map(|expr| match expr {
                        Expression::Variadic(Operator::Mul, mut exprs) => {
                            if !exprs
                                .iter()
                                .any(|expr| matches!(expr, Expression::Lit(Term::Numeric(_))))
                            {
                                exprs.push(Expression::integer_expression(1));
                            }

                            Expression::Variadic(Operator::Mul, exprs)
                        }
                        expr @ Expression::Lit(Term::Numeric(_)) => expr,
                        other => Expression::Variadic(
                            Operator::Mul,
                            vec![Expression::integer_expression(1), other],
                        ),
                    })
                    .collect();
                Expression::Variadic(Operator::Add, exprs)
            }
            other => other.apply_on_others(Expression::explicit_coefficients),
        }
    }
//Makes all expressions under an addition node products. Makes it easier to group them.
Makes all expressions under an addition node products. Makes it easier to group them.
Makes all expressions under an addition node products . Makes it easier to group them .
pub fn explicit_coefficients(self) -> Expression {
        match self {
            Expression::Variadic(Operator::Add, exprs) => {
                let exprs = exprs
                    .into_iter()
                    .map(Expression::explicit_coefficients)
                    .map(|expr| match expr {
                        Expression::Variadic(Operator::Mul, mut exprs) => {
                            if !exprs
                                .iter()
                                .any(|expr| matches!(expr, Expression::Lit(Term::Numeric(_))))
                            {
                                exprs.push(Expression::integer_expression(1));
                            }
                            Expression::Variadic(Operator::Mul, exprs)
                        }
                        expr @ Expression::Lit(Term::Numeric(_)) => expr,
                        other => Expression::Variadic(
                            Operator::Mul,
                            vec![Expression::integer_expression(1), other],
                        ),
                    })
                    .collect();
                Expression::Variadic(Operator::Add, exprs)
            }
            other => other.apply_on_others(Expression::explicit_coefficients),
        }
    }
pub fn explicit_coefficients ( self ) -> Expression { match self { Expression :: Variadic ( Operator :: Add , exprs ) => { let exprs = exprs . into_iter ( ) . map ( Expression :: explicit_coefficients ) . map ( | expr | match expr { Expression :: Variadic ( Operator :: Mul , mut exprs ) => { if ! exprs . iter ( ) . any ( | expr | matches ! ( expr Expression Lit ( Term Numeric ( ) ) ) ) { exprs . push ( Expression :: integer_expression ( 1 ) ) ; } Expression :: Variadic ( Operator :: Mul , exprs ) } expr @ Expression :: Lit ( Term :: Numeric ( _ ) ) => expr , other => Expression :: Variadic ( Operator :: Mul , vec ! [ Expression integer_expression ( 1 ) other ] , ) , } ) . collect ( ) ; Expression :: Variadic ( Operator :: Add , exprs ) } other => other . apply_on_others ( Expression :: explicit_coefficients ) , } }
Makes all expressions under an addition node products.
Makes all expressions under an addition node products .
self
self