Is it a list ?

Bjarne Däcker bjarne@REDACTED
Thu Jul 10 21:21:27 CEST 2003


Hello

I think that this is a matter of history.

Probably very early in Lisp they were
more thinking in terms of binary trees

((1 . 2) . (3 . 4))

which in Erlang would be

[[1 | 2] | [3 | 4]]

and then the idea of lists appeared

(1 . (2 . (3 . (4 . nil))))

and a special syntax evolved

(1 2 3 4)

but the "dotted pair" survived just
like in English people say "geese"
instead of "gooses".

In Lisp you can write

(1 2 3 4 . 5) 

which in Erlang becomes

[1, 2, 3, 4 | 5]

where the last element is not
[] or [5] but, in fact, simply 5.

The space saving is negligeable
but you could use this to write
clever programs that others
find difficult to understand.

Thus arose the notion of
well-formedness.

Bjarne






More information about the erlang-questions mailing list