Improper lists [was: Dialyzer v1.3.0 released]

David Hopwood <>
Thu Mar 31 03:06:57 CEST 2005


Matthias Lang wrote:
>  Matt> > It's possible to see it the other way around. Cons cells are
>  Matt> > universal.                                    ^^^^^^^^^^
> 
>  James> True.  But the way I see it, the fundamental difference is that lists
>  James> are designed...                                                 ^^^^^
> 
> All lists are made of cons cells.
> But not all cons cells are part of a list.
> 
> Wasn't that the whole point?

Depends on the language. In Haskell for example, and in other languages
where cons cells are defined as the algebraic data type

   List t ::= Nil | Cons t (List t),

lists are always proper.

> http://www.gigamonkeys.com/book/beyond-lists-other-uses-for-conses.html

This representation of trees uses only proper lists (where each list is the
right spine of the corresponding subtree).

-- 
David Hopwood <>




More information about the erlang-questions mailing list