> I can't imagine how you would even implement a string as anything other than a rune array.
You can also implement strings using a tree data structure. We do this in an implementation of Ruby that I work on because it can make concatenation faster.
A text editor edits a (potentially very long) string, but apart from, possibly, the likes of Notepad, none of them store that string as a single byte array.
So, look at text editor data structures for other representations. Examples:
barsonme|9 years ago
Someone|9 years ago
razakel|9 years ago
I can't imagine how you would even implement a string as anything other than a rune array.
Even a Pascal string is just the string length followed by characters.
chrisseaton|9 years ago
You can also implement strings using a tree data structure. We do this in an implementation of Ruby that I work on because it can make concatenation faster.
Someone|9 years ago
So, look at text editor data structures for other representations. Examples:
- https://en.wikipedia.org/wiki/Gap_buffer
- https://en.wikipedia.org/wiki/Rope_(computer_science)
- https://en.wikipedia.org/wiki/Piece_table
unwind|9 years ago
Also not a Haskell programmer, and really not meaning to criticize. Haskell seems awesome and I should learn it some day.
thwd|9 years ago