-
-
Save jamii/43d49246934839102f6fed35c7b68978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rightmost_child: edits.?edit edit parent~ @ max; | |
fix rightmost_leaf: edits.?edit edit | edit rightmost_child rightmost_leaf @ max; | |
prev_sibling: edits.?edit edit parent parent~ .(?sibling edit > sibling) @ max; | |
prev: edits.?edit edit prev_sibling !! then edit prev_sibling rightmost_leaf else edit parent; | |
fix position: root, 0 | position ?edit ?pos edit prev~, pos + 1; | |
edits ?edit (edit position), edit, (edit character) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rightmost_child = edits (?edit . edit . | |
(max [edit ~parent])) in | |
let rightmost_leaf = | |
fix none (?[rightmost_leaf] . | |
edits (?edit . edit . | |
(max [edit | (edit rightmost_leaf rightmost_child)])))) in | |
let prev_sibling = edits (?edit . edit | |
(max [(edit parent ~parent) (?sibling . (when (edit > sibling) sibling))])) in | |
let prev = edits (?edit . edit . | |
if !!(prev_sibling edit) | |
([prev_sibling edit] max rightmost_leaf) | |
(edit parent)) in | |
let position = | |
fix none (?[position] . | |
edits (?edit . edit . | |
if !(edit parent) then 0 else | |
(edit prev position) + 1)) in | |
edits (?edit . | |
(edit position) . edit . (edit character)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment