[erlang-questions] ++ operator

Richard O'Keefe ok@REDACTED
Thu Nov 1 06:42:00 CET 2012

On 1/11/2012, at 6:24 AM, Michał Ptaszek wrote:
> Does Erlang have a built-in optimizations such as?:
> ++([], B) -> B;
> ++(A, B) -> lists:append([A, B]).

Other way around.  In lib/stdlib*/src/lists.erl you'll find

	append(L1, L2) -> L1 ++ L2.

It is important that the cost of Xs++Ys (append(Xs, Ys)) should
depend only on the size of Xs, and that means Ys does not get
looked at at all.

More information about the erlang-questions mailing list