add to_string function

This commit is contained in:
Humza Shahid
2023-11-13 09:03:29 +00:00
parent 6cd3db9104
commit 137fe24ef5
6 changed files with 2916 additions and 2672 deletions

View File

@@ -13,6 +13,7 @@ exception Size
exception Ins
exception Substring
exception Delete
exception To_string
fun size rope =
case rope of
@@ -374,3 +375,24 @@ fun delete start length rope =
in
t
end
fun to_str acc rope =
case rope of
N0 str =>
(str::acc)
| N1 t =>
to_str acc t
| N2 (l, _, _, r) =>
let
val acc = to_str acc r
in
to_str acc l
end
| _ => raise To_string
fun to_string rope =
let
val lst = to_str [] rope
in
String.concat lst
end