[erlang-questions] List pipe syntax
Samuel Rivas
samuelrivas@REDACTED
Tue Dec 19 08:24:33 CET 2006
Alexander Harju wrote:
> Hi,
> I have a question about the pipe syntax when building lists.
> According to the Erlang reference a list is either the empty list [] or
> consists of a head and a tail which is also a list. [Head|Tail].
> I've noticed that you can do some weird "list"-building using the pipe
> syntax.
> [1|[]] is obviously a list according to the definition since [] is a list.
> But what about [1|2]??. This shouldn't evaluate to a list since 2 isn't a
> list.
Note that also according to the reference:
"A list where the tail is a list is sometimes called a proper list. It is
allowed to have a list where the tail is not a list, for example [a|b].
However, this type of list is of little practical use."
Regards.
--
Samuel
More information about the erlang-questions
mailing list