[racket] StringBuilder for Racket?
> I have a trivial task: read a null-terminated string from a stream.
> The size of the string has no predefined limit. How do I do that
> in Racket? I need some resizable thing to store characters,
> like vector<char> in C++ or StringBuilder in C# or Java.
> Does Racket have one?
>
>
Hi Dmitry,
You can use an output-string-port for this purpose. Use the
"open-output-string" to create an output port, and write to it using the
standard port-writing functions. Finally, use "get-output-string" to get
the final, concatenated result.
Example:
> (define op (open-output-string))
> (display "hello" op)
> (display "world" op)
> (get-output-string op)
"helloworld"
For more information, see:
http://docs.racket-lang.org/guide/ports.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121126/4ccb7469/attachment.html>