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

Function getSequence

src/math-json/utils.ts:432–448  ·  view source on GitHub ↗
(
  expr: MathJsonExpression | null | undefined
)

Source from the content-addressed store, hash-verified

430 if (rhsName === op) return [op, lhs, ...operands(rhs)];
431 return [op, lhs, rhs];
432}
433
434/** Return the elements of a sequence, or null if the expression is not a sequence. The sequence can be optionally enclosed by a`["Delimiter"]` expression */
435export function getSequence(
436 expr: MathJsonExpression | null | undefined
437): ReadonlyArray<MathJsonExpression> | null {
438 if (expr === null || expr === undefined) return null;
439
440 let h = operator(expr);
441 if (h === 'Delimiter') {
442 expr = operand(expr, 1);
443 if (expr === null) return [];
444 h = operator(expr);
445 if (h !== 'Sequence') return [expr!];
446 }
447
448 if (h !== 'Sequence') return null;
449
450 return operands(expr);
451}

Callers 4

parseArgumentsMethod · 0.90
getSequenceOrTupleFunction · 0.90

Calls 3

operandFunction · 0.85
operandsFunction · 0.85
operatorFunction · 0.70

Tested by

no test coverage detected