THE FOLD / CHEAT / NOCLIP / THE ZIPPER
THE ZIPPER
a cursor that splits the list
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The zipper is a purely functional data structure for editing a sequence (or tree) at a moving focus, with O(1) local operations and no mutation. A list zipper splits the sequence into three parts: the elements to the left of the cursor (held reversed, so the nearest is on top), the focused element, and the elements to the right. Moving the cursor pops from one side and pushes to the other; inserting or deleting at the focus touches only the front of a list. Nothing is copied or shifted — the whole sequence is always recoverable as left ++ [focus] ++ right, which makes undo and immutable sharing natural.
LIT verified live: over 5000 runs of 20 random moves, inserts, and deletes, the list reconstructed from the zipper exactly equals the same edits applied to a plain array with a cursor index (window.__zipper). FIG no framing; the zipper operations and a plain-array reference run in-browser.
LIT verified live: over 5000 runs of 20 random moves, inserts, and deletes, the list reconstructed from the zipper exactly equals the same edits applied to a plain array with a cursor index (window.__zipper). FIG no framing; the zipper operations and a plain-array reference run in-browser.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at noclip — a cursor that moves freely through the structure and edits in place without ever shifting the rest. AVAN (AI) built the instrument: the left/focus/right split, the move/insert/delete operations, and the plain-array cross-check.
Credit as content: Gérard Huet (“The Zipper”, 1997). The weave: David names noclip; I confirm the three-part split reconstructs exactly the edited sequence at every step.
Credit as content: Gérard Huet (“The Zipper”, 1997). The weave: David names noclip; I confirm the three-part split reconstructs exactly the edited sequence at every step.
3 ONE DIMENSION
The sequence split into left / focus / right; the document is always left ++ focus ++ right.
4 TWO DIMENSIONS · INTERACTIVE
Move the cursor and edit at the focus; the reconstruction stays equal to a plain array with the same edits.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: the sequence, reconstructed from the split.
AVAN’s addition (the inverse-companion): don’t index into an array — carry the context. The inverse of ‘edit arr[i], shifting the tail’ is ‘split at the focus; insert/delete touch only the front of a list, O(1).’ Magenta is the focus; green is the whole sequence it sits inside. The cursor carries its context.
LIT Genuine zipper data structure (Gérard Huet, 'The Zipper', J. Functional Programming 1997). Verified live: over 5000 runs of 20 random move/insert/delete operations, the list reconstructed from the (left, focus, right) split equals the same edits on a plain array with a cursor index at every step (window.__zipper.matchesArray).
FIG No framing: the zipper operations and a plain-array reference run in-browser. The AVAN inverse is honest — instead of indexing an array and shifting the tail on each edit, the zipper carries its context: split at the focus, and insert/delete touch only the front of a list, O(1). Magenta is the focus; green is the whole sequence it sits inside. The cursor carries its context.
FIG No framing: the zipper operations and a plain-array reference run in-browser. The AVAN inverse is honest — instead of indexing an array and shifting the tail on each edit, the zipper carries its context: split at the focus, and insert/delete touch only the front of a list, O(1). Magenta is the focus; green is the whole sequence it sits inside. The cursor carries its context.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of NOCLIP · David Lee Wise (ROOT0), with AVAN