( x: MathJSON, variables: ReadonlyArray<string> )
| 163 | // --------------------------------------------------------------------------- |
| 164 | |
| 165 | /** Rename each entry variable `z` to the wildcard `_z` (pure tree rewrite). */ |
| 166 | export function wildcardize( |
| 167 | x: MathJSON, |
| 168 | variables: ReadonlyArray<string> |
| 169 | ): MathJSON { |
| 170 | if (typeof x === 'string') return variables.includes(x) ? '_' + x : x; |
| 171 | if (Array.isArray(x)) return x.map((y) => wildcardize(y, variables)); |
| 172 | return x; |
| 173 | } |
| 174 | |
| 175 | /** Substitute wildcard symbols by MathJSON fragments. */ |
no test coverage detected