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

Function partOfVariable

scripts/fungrim/compile-rules.ts:259–273  ·  view source on GitHub ↗

`[PartHead, v]` for an entry variable `v` → the part tag, else null.

(
  x: MathJSON,
  variables: ReadonlyArray<string>
)

Source from the content-addressed store, hash-verified

257 x: MathJSON,
258 variables: ReadonlyArray<string>
259): { part: 're' | 'im' | 'abs' | 'arg'; v: string } | null {
260 if (
261 Array.isArray(x) &&
262 x.length === 2 &&
263 typeof x[0] === 'string' &&
264 x[0] in PART_HEADS &&
265 typeof x[1] === 'string' &&
266 variables.includes(x[1])
267 )
268 return { part: PART_HEADS[x[0]], v: x[1] };
269 return null;
270}
271
272/**
273 * Compile entry assumptions to a GuardSpec list. Fail-closed: any conjunct
274 * outside the mapping table makes the whole entry uncompilable.
275 */
276export function compileGuards(

Callers 1

compileGuardsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected