(u: Expression, v: Expression)
| 1225 | for (let i = 0; i < n; i++) if (a[i] !== b[i]) return a[i] < b[i]; |
| 1226 | return a.length < b.length; |
| 1227 | } |
| 1228 | |
| 1229 | function collectSymbolLeaves(e: Expression, out: string[]): void { |
| 1230 | if (e.symbol) { |
| 1231 | out.push(e.symbol); |
| 1232 | return; |
| 1233 | } |
| 1234 | // monomial degree matters: a·d² keys as [a,d,d] (else it compares |
| 1235 | // equal-prefix-shorter against b·c·d and steals First[] from it) |
| 1236 | if (e.operator === 'Power' && e.ops) { |
| 1237 | const k = e.ops[1].re; |
| 1238 | if (e.ops[1].isInteger && typeof k === 'number' && k > 1 && k <= 16) { |
| 1239 | const inner: string[] = []; |
| 1240 | collectSymbolLeaves(e.ops[0], inner); |
| 1241 | for (let i = 0; i < k; i++) out.push(...inner); |
| 1242 | return; |
| 1243 | } |
| 1244 | } |
| 1245 | if (e.ops) for (const op of e.ops) collectSymbolLeaves(op, out); |
| 1246 | } |
| 1247 | |
| 1248 | function mapList(arg: Json, ctx: Ctx, f: (u: Expression) => boolean): boolean { |
| 1249 | const items = |
no test coverage detected