MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / wildcardize

Function wildcardize

scripts/fungrim/compile-rules.ts:165–172  ·  view source on GitHub ↗
(
  x: MathJSON,
  variables: ReadonlyArray<string>
)

Source from the content-addressed store, hash-verified

163// ---------------------------------------------------------------------------
164
165/** Rename each entry variable `z` to the wildcard `_z` (pure tree rewrite). */
166export 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. */

Callers 3

WFunction · 0.85
compileEntriesFunction · 0.85

Calls 1

mapMethod · 0.65

Tested by

no test coverage detected