[erlang-questions] Coming Back (maybe improving lists:reverse/1)

Cian Synnott <>
Wed Oct 7 21:47:57 CEST 2015


Hi Ivan,

On Wed, Oct 7, 2015 at 7:39 PM, Ivan Carmenates Garcia
<> wrote:
> lists module, and doing some recursive functions, it is usually a problem
> that we need to do lists:reverse at the end of the algorism to get the data
> in the right order.
>
Are you sure that it's a problem, e.g. do you have very long lists, or
measurements that demonstrate an issue?

See http://emauton.org/2015/01/25/lists:reverse-1-performance-in-erlang/
for a brief note on why you probably don't need to worry about this.
:o)

> So I can imagine Erlang implement lists using double linked lists for
> obvious purposes,
>
They're singly-linked - this is why we tend to build them in "reverse
order" in the first place.

Cian


More information about the erlang-questions mailing list