Is it a list ?

Bijan Parsia bparsia@REDACTED
Thu Jul 10 22:19:48 CEST 2003


On Thu, 10 Jul 2003, Bjarne Däcker wrote:

> Hello
>
> I think that this is a matter of history.

I'm skeptical.

> Probably very early in Lisp they were
> more thinking in terms of binary trees
>
> ((1 . 2) . (3 . 4))

I strongly doubt it. I mean, yes, cons cells/pairs are for binary trees.

> 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)

This
	http://www8.informatik.uni-erlangen.de/html/lisp/histlit1.html

suggests otherwise.

(Search for "To accomplish this McCarthy had to find a notation")

Binary tree is just one implementation of lists.

Cons cells are more generall just lists.

> 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.

Well, they also have some actually reasonable uses. E.g., association
lists, see

http://www.cs.auc.dk/~normark/prog3-02/html/notes/fu-intr-1-slide-alists.html

The space savings is proportional to the length of the alist.

And, it's not merely a space optimization for circular lists:

	http://www.lispworks.com/reference/HyperSpec/Body/14_ab.htm

Of course, whether one *should* use them is a different story. One debate:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=gat-0309021628320001%40192.168.1.50&rnum=13&prev=/groups%3Fq%3Ddotted%2Blists%2Bgroup:comp.lang.lisp.*%2Bgroup:comp.lang.lisp.*%2Bgroup:comp.lang.lisp.*%2Bgroup:comp.lang.lisp.*%26hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.lang.lisp.*%26start%3D10%26sa%3DN

Another more interesting one:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=gat-2002021351120001%40eglaptop.jpl.nasa.gov&rnum=1&prev=/groups%3Fselm%3Dgat-2002021351120001%2540eglaptop.jpl.nasa.gov

Cheers,
Bijan Parsia.




More information about the erlang-questions mailing list