[erlang-questions] output [[[[]|2]|1]|0] instead of [2.1.0]

Loïc Hoguin essen@REDACTED
Tue Feb 10 15:42:23 CET 2015

You are creating what is called an improper list.

This is a proper list:


This is the same list using the | operator:


Now what happens if you write this, for example?


It still works. This is called an improper list. An improper list is a 
list where the tail is not a list.

When you do A++B Erlang will only ensure that A is a list. B can be 
anything. If it's not a list, however, then you end up with an improper 

I advise you to avoid ++ when doing most list related exercices, go with 
the | operator instead.

On 02/10/2015 03:19 PM, Roelof Wobben wrote:
> Hello,
> I have to make a reversed list to a number so reverse_list(2) will
> output [2.1]

Loïc Hoguin

More information about the erlang-questions mailing list