[racket] StringBuilder for Racket?

From: Danny Yoo (dyoo at hashcollision.org)
Date: Mon Nov 26 13:30:08 EST 2012

> 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.


> (define op (open-output-string))
> (display "hello" op)
> (display "world" op)
> (get-output-string op)

For more information, see:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121126/4ccb7469/attachment.html>

Posted on the users mailing list.