Skip to content

Instantly share code, notes, and snippets.

@robertpfeiffer
Created July 28, 2010 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertpfeiffer/494341 to your computer and use it in GitHub Desktop.
Save robertpfeiffer/494341 to your computer and use it in GitHub Desktop.
let rec iterate fn prop start =
if prop start then start
else iterate fn prop (fn start)
let rec next node =
if is_left node then node |> right |> up |> firstChild
else node |> iterate up is_left |> next
let rec delete n off node =
let newnode = node |> toString |> boundedsubstring n off |> fromString
let rem = n + off - length node
if rem > 0 then delete rem 0 (next newnode)
else newnode
let rec insert off node text =
let left = (subrope 0 off node)
let right = (subrope off (len node - off) node)
concat left (concat text right)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment