<d_bot>
<carmysilna> what would be the most efficient way to insert a `char` into a `string` at a given index, using `batteries` or `Stdlib`? Right now I'm converting the string to a list and then into a vect, inserting, then converting back into a list and then a string. but that seems horribly inefficient
bartholin has quit [Ping timeout: 268 seconds]
<rom1504>
inserting in an array is inefficient
<thizanne>
you could do something looking like `let (left, right) = split your_string your_index in String.concat [left; String.make 1 your_char; right]`
<thizanne>
(probably not the right function names)
<thizanne>
but that still wouldn't be ideally efficient, so if that's performance sensitive you might want to user another structure than strings
adanwan has quit [Ping timeout: 276 seconds]
<d_bot>
<carmysilna> should I store them as a Vect instead so its a rope? this is for a text editor, if that helps
[itchyjunk] has quit [Remote host closed the connection]
hendursaga has joined #ocaml
waleee has quit [Ping timeout: 252 seconds]
waleee has joined #ocaml
bartholin has quit [Ping timeout: 268 seconds]
ppw has joined #ocaml
ppw has left #ocaml [#ocaml]
xd1le has quit [Quit: xd1le]
average has quit [Quit: Connection closed for inactivity]
gareppa has joined #ocaml
gareppa has quit [Remote host closed the connection]
gravicappa has quit [Ping timeout: 265 seconds]
gravicappa has joined #ocaml
<d_bot>
<Bluddy> There is no great solution for string editing. Rope is the functional solution, but probably the more efficient option is a vector. I think what editors do is that they store each line in a different vector.
<d_bot>
<darrenldl> a gap buffer for each line would be speedy enough right?
<d_bot>
<carmysilna> well, my lines are very short in practice (1-5 chars maybe?) because ||this is a structured editor for mlatu (where you edit the AST) and I'm making each term appear on its own line. so when someone inserts a char, it just needs to be inserted into the rendered string and then re-parsed || tldr: I have a short `string` that will be need to be re-converted into a `string` at the end of the insert operation, as efficiently as po
bartholin has joined #ocaml
mro has joined #ocaml
mro has quit [Read error: Connection reset by peer]
mro has joined #ocaml
[itchyjunk] has joined #ocaml
[_] has joined #ocaml
[_] has quit [Remote host closed the connection]
[itchyjunk] has quit [Remote host closed the connection]
[itchyjunk] has joined #ocaml
mro has quit [Client Quit]
Everything has quit [Quit: leaving]
bartholin has quit [Ping timeout: 265 seconds]
brettgilio has quit [Ping timeout: 252 seconds]
Serpent7776 has quit [Quit: leaving]
bartholin has joined #ocaml
terrorjack has quit [Remote host closed the connection]
terrorjack has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
brettgilio has joined #ocaml
bartholin has quit [Quit: Leaving]
average has joined #ocaml
hackinghorn has joined #ocaml
<d_bot>
<salt rock lamp> I heard once that Vim stores text as a vector of strings, one per line