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

Function flatBinaryOp

scripts/rubi/wl-parser.ts:376–383  ·  view source on GitHub ↗
(op: string, a: Json, b: Json)

Source from the content-addressed store, hash-verified

374}
375
376function flatBinaryOp(op: string, a: Json, b: Json): Json {
377 const ops: Json[] = [];
378 for (const x of [a, b]) {
379 if (Array.isArray(x) && x[0] === op) ops.push(...(x as Json[]).slice(1));
380 else ops.push(x);
381 }
382 return [op, ...ops];
383}
384
385function flatBinary(op: 'Add' | 'Multiply', a: Json, b: Json): Json {
386 return flatBinaryOp(op, a, b);

Callers 2

parseExpressionMethod · 0.85
flatBinaryFunction · 0.85

Calls 1

sliceMethod · 0.65

Tested by

no test coverage detected