<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Given you generate chunks of HTML and that this will undoubtedly be
pushed over a socket at some point, what you want to use is IO
Lists.<br>
<br>
They are lists of either bytes (integers from 0 to 255), binaries,
or other IO lists. This means that functions that accept IO lists
can accept items such as <tt>[$H, $e, [$l, <<"lo">>, "
"], [[["W","o"], <<"rl">>]] | [<<"d">>]]</tt>.
When this happens, the Erlang VM will just flatten the list as it
needs to do it to obtain the sequence of characters <tt>Hello World</tt>.<br>
<br>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
Any function from the io module, file module, TCP and UDP sockets
will be able to handle them. Some library functions, such as some
coming from the unicode module and all of the functions from the re
(for regular expressions) module will also handle them, to name a
few.<br>
<br>
So in your case, to join string A and B, no matter whether they're
binaries or lists, just do <tt>[A,B]</tt> and that's your new
string. You'll save a lot in terms of rewriting terms and whatnot
doing things that way.<br>
<br>
On 12-05-07 9:31 AM, Paul Barry wrote:
<blockquote
cite="mid:CAFwVEOS68U8W45BKWNf4KJ+oV8H1_rTo2DFBJLSWLm-M9ok1Xw@mail.gmail.com"
type="cite">
<pre wrap="">Hi folks.
This might be a case of a dumb question, but here goes anyway. :-)
I have two strings, A and B. Is it better to use:
string:concat(A, B)
or
A ++ B
when combining them to create a new string? I'm writing some code
that generates a chunk of HTML. I know that using ++ on big lists is
regarded as a "no-no", but is it acceptable here?
Thanks.
Paul.
</pre>
</blockquote>
</body>
</html>