( x: Expression | undefined )
| 183 | */ |
| 184 | const TRANSFORMER_HEADS = new Set([ |
| 185 | 'Simplify', |
| 186 | 'Expand', |
| 187 | 'ExpandAll', |
| 188 | 'Factor', |
| 189 | 'Together', |
| 190 | 'Distribute', |
| 191 | 'TrigExpand', |
| 192 | ]); |
| 193 | |
| 194 | /** |
| 195 | * Reduce a held (already canonical) operand whose head is an |
| 196 | * expression-transformer (see `TRANSFORMER_HEADS`) so that a structural |
| 197 | * algorithm sees the transformed expression rather than the transformer |
| 198 | * call. Any other expression is returned unchanged. |
| 199 | */ |
| 200 | export function reduceTransformerHead(expr: Expression): Expression { |
| 201 | return reduceTransformerHeads(inlineLambdaApplications(expr)); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Reduce transformer heads anywhere in `expr`, not only at its root: in |
| 206 | * `Solve(Simplify(u) = 2, w)` the transformer sits inside the `Equal`, so a |
| 207 | * root-only check left it opaque and the solve returned `[]`. |
no test coverage detected