[−][src]Module libslide::partial_evaluator::flatten
This module tries to flatten expressions as far as possible without the intervention of more complex evaluation rules. Flattening might be used as a "first pass" to normalize an expression, or by a more complex rule for the same reason.
Examples
Targets of this module
1 + 2 + 3 -> 6
1 - 5x / x -> -4
Non targets of this module
x^2 + 4x + 4 -> (x + 2)^2
Functions
flatten_add_or_sub | Flattens an addition or subtraction, folding constants and like terms as far as possible. The flattened expression is always normalized to an addition. |
flatten_expr | Attempts to flatten an expression, folding constant expressions and like terms. |
flatten_mul_or_div | Flattens a multiplication or division, folding constants and like terms as far as possible. The flattened expression is always normalized to a multiplication. |
unwrap_expr | Unwraps an expression in parentheses/brackets, or returns the original expression if it cannot be unwrapped. |