pub fn to_expr(&self, relative_to: RcExpr, span: crate::Span) -> RcExpr {
        let mut terms = Vec::with_capacity(self.vec.len());
        for (pow, coeff) in self.vec.iter().enumerate() {
            let term = match coeff {
                0 => {
                    continue;
                }
                1 => relative_to.clone(),
                _ => rc_expr!(
                    Expr::BinaryExpr(BinaryExpr::mult(
                        rc_expr!(Expr::Const(*coeff as f64), span),
                        relative_to.clone()
                    )),
                    span
                ),
            };

            terms.push(match pow {
                0 => rc_expr!(Expr::Const(*coeff as f64), span),
                1 => term,
                _ => rc_expr!(
                    Expr::BinaryExpr(BinaryExpr::exp(
                        term,
                        rc_expr!(Expr::Const(pow as f64), span),
                    )),
                    span
                ),
            });
        }
        if terms.is_empty() {
            return rc_expr!(Expr::Const(0.), span);
        }

        unflatten_binary_expr(
            terms.as_ref(),
            BinaryOperator::Plus,
            UnflattenStrategy::Left,
        )
    }
/// Converts a [Poly](self::Poly) polynomial, relative to some term, into an expression.
///
/// A artificial `span` the elements of the converted expression are derived from must be
/// provided. In general, `span` should be the span of an expression previously converted the
/// `Poly` this method is called on.
///
/// ## Examples
///
/// ```ignore
/// poly![1, 2, 3].to_expr("x") == "3 * (x ^ 2) + 2 * x + 1"
/// ```
Converts a [Poly](self::Poly) polynomial, relative to some term, into an expression.
A artificial `span` the elements of the converted expression are derived from must be
provided. In general, `span` should be the span of an expression previously converted the
`Poly` this method is called on.
Converts a [ Poly ] ( self :: Poly ) polynomial relative to some term into an expression . A artificial ` span ` the elements of the converted expression are derived from must be provided . In general ` span ` should be the span of an expression previously converted the ` Poly ` this method is called on .
pub fn to_expr(&self, relative_to: RcExpr, span: crate::Span) -> RcExpr {
        let mut terms = Vec::with_capacity(self.vec.len());
        for (pow, coeff) in self.vec.iter().enumerate() {
            let term = match coeff {
                0 => {
                    continue;
                }
                1 => relative_to.clone(),
                _ => rc_expr!(
                    Expr::BinaryExpr(BinaryExpr::mult(
                        rc_expr!(Expr::Const(*coeff as f64), span),
                        relative_to.clone()
                    )),
                    span
                ),
            };
            terms.push(match pow {
                0 => rc_expr!(Expr::Const(*coeff as f64), span),
                1 => term,
                _ => rc_expr!(
                    Expr::BinaryExpr(BinaryExpr::exp(
                        term,
                        rc_expr!(Expr::Const(pow as f64), span),
                    )),
                    span
                ),
            });
        }
        if terms.is_empty() {
            return rc_expr!(Expr::Const(0.), span);
        }
        unflatten_binary_expr(
            terms.as_ref(),
            BinaryOperator::Plus,
            UnflattenStrategy::Left,
        )
    }
pub fn to_expr ( & self , relative_to : RcExpr , span : crate :: Span ) -> RcExpr { let mut terms = Vec :: with_capacity ( self . vec . len ( ) ) ; for ( pow , coeff ) in self . vec . iter ( ) . enumerate ( ) { let term = match coeff { 0 => { continue ; } 1 => relative_to . clone ( ) , _ => rc_expr ! ( Expr BinaryExpr ( BinaryExpr mult ( rc_expr ( Expr Const ( coeff as f64 ) span ) relative_to clone ( ) ) ) span ) , } ; terms . push ( match pow { 0 => rc_expr ! ( Expr Const ( coeff as f64 ) span ) , 1 => term , _ => rc_expr ! ( Expr BinaryExpr ( BinaryExpr exp ( term rc_expr ( Expr Const ( pow as f64 ) span ) ) ) span ) , } ) ; } if terms . is_empty ( ) { return rc_expr ! ( Expr Const ( 0. ) span ) ; } unflatten_binary_expr ( terms . as_ref ( ) , BinaryOperator :: Plus , UnflattenStrategy :: Left , ) }
Converts a [Poly](self::Poly) polynomial, relative to some term, into an expression.
Converts a [ Poly ] ( self :: Poly ) polynomial relative to some term into an expression .
&self
relative_to
RcExpr
span
crate::Span
&self
relative_to
RcExpr
span
crate::Span
examples
None