[erlang-questions] list:join() for erlang?
Sat Sep 15 06:23:36 CEST 2007
Paulo Sérgio Almeida wrote:
> Regarding list reverse, while playing around and observing:
> 85> erlang:is_builtin(lists, reverse, 1).
> I found out that what is builtin is another function, reverse/2, which
> is not much advertised, but that may be very useful, as the fastest way
> to simultaneously reverse a list and concatenate to another.
From lists.erl, reverse/1 calls reverse/2 to do the actual reversing,
except in a couple of special cases (where length(L) < 3).
reverse( = L) ->
reverse([_] = L) ->
reverse([A, B]) ->
reverse([A, B | L]) ->
lists:reverse(L, [B, A]).
More information about the erlang-questions