[erlang-questions] Which is best? string:concat or ++?

Paul Barry paul.james.barry@REDACTED
Mon May 7 16:02:39 CEST 2012


Thanks for the quick responses, Paul and Fredrik.  That's cleared
things up for me (as well as given me another way to accomplish what I
need).  Cheers. :-)

On 7 May 2012 14:45, Fredrik Andersson <sedrik@REDACTED> wrote:
> I would recommend also looking at
> http://www.erlang.org/doc/man/lists.html#concat-1
>
> On Mon, May 7, 2012 at 3:37 PM, Paul Davis <paul.joseph.davis@REDACTED> wrote:
>> Quick scan of the source shows that string:concat/2 is exactly the ++
>> operator. So using ++ will save you a function invocation assuming the
>> Erlang compiler doesn't optimize that away.
>>
>> https://github.com/erlang/otp/blob/maint/lib/stdlib/src/string.erl#L61
>>
>> On Mon, May 7, 2012 at 8:31 AM, Paul Barry <paul.james.barry@REDACTED> wrote:
>>> 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.
>>>
>>> --
>>> Paul Barry, w: http://paulbarry.itcarlow.ie - e: paul.barry@REDACTED
>>> Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions



-- 
Paul Barry, w: http://paulbarry.itcarlow.ie - e: paul.barry@REDACTED
Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.



More information about the erlang-questions mailing list