/** * PersistentList — an immutable singly-linked list (cons cells). * * Used as the continuation stack in Phase 2. Forking is O(1): to take * a multi-shot continuation, keep the reference. Calling `resume` twice * restarts from the same immutable stack snapshot without copying. * * Performance characteristics: * cons(v, list) O(1) * head / tail O(1) * isEmpty O(1) */ export type PersistentList = null | PersistentListNode; export interface PersistentListNode { readonly head: T; readonly tail: PersistentList; } /** Prepend `value` to `list`. */ export declare function cons(value: T, list: PersistentList): PersistentListNode; /** Returns true if `list` is empty. */ export declare function isEmpty(list: PersistentList): list is null; /** Convert a PersistentList to a plain JS array. O(N). */ export declare function listToArray(list: PersistentList): T[]; /** Build a PersistentList from a plain JS array. O(N). Head of list = first element. */ export declare function listFromArray(arr: T[]): PersistentList; /** Return the first `n` elements as a new list. O(N). */ export declare function listTake(list: PersistentList, n: number): PersistentList; /** Skip the first `n` elements and return the rest. O(N). */ export declare function listDrop(list: PersistentList, n: number): PersistentList; /** * Prepend all elements of `arr` to `list`. * First element of `arr` becomes the new head. O(N). * Used for stack reconstruction: e.g. [...innerFrames, handler, ...outerK]. */ export declare function listPrependAll(arr: readonly T[], list: PersistentList): PersistentList; /** Return the number of elements in the list. O(N). */ export declare function listSize(list: PersistentList): number;