substDefs

tcmts.core.analyze.substDefs · #otk3clkp · term · runs anywhere

import type { IR } from "#codebase/tcmts/core/hash";

export function substDefs(ir: IR, f: (def: number) => IR): IR {
  if (typeof ir === "string") return ir;
  if (ir[0] === "@def" && ir.length === 2) return f(Number(ir[1]));
  return ir.map((c) => substDefs(c, f));
}

uses

used by