/** F2 — Memory monomers: MC_16–MC_23 */ export const load = (mem: T[], i: number): T | undefined => mem[Math.trunc(i)]; export const store = (mem: T[], i: number, v: T): boolean => { const idx = Math.trunc(i); if (idx < 0 || idx >= mem.length) return false; mem[idx] = v; return true; }; export const push = (stack: T[], v: T): void => { stack.push(v); }; export const pop = (stack: T[]): T | undefined => stack.pop(); export const peek = (stack: T[]): T | undefined => stack[stack.length - 1]; export const alloc = (n: number): number[] => new Array(Math.min(Math.trunc(n), 65536)).fill(0); export const free = (mem: unknown[]): void => { mem.length = 0; }; export const lenMem = (mem: unknown[]): number => mem.length;