by liancheng · 14y ago · 0 comments
Just check your /usr/lib/erlang/lib/stdlib-xxx/src/string.erl, and you'll find this:
concat(S1, S2) -> S1 ++ S2.
and "++" is obviously a O(N) operator.But yes, string concatenation is somewhat faster than other languages that represent strings with arrays of characters. Because in Erlang, it's O(N), while in others it's O(N+M), where N is the length of the first string and M is the length of the second.
Maybe here you can find a bit better explanation: http://erlang.org/pipermail/erlang-questions/2012-May/066590...