checking if a list is empty

Jussi Piitulainen jpiitula at ling.helsinki.fi
Sun May 8 11:59:44 EDT 2011


Steven D'Aprano writes:

> Lisp uses the empty list and the special atom NIL as false values,
> any other s-expression is true. Scheme is different: it defines a
> special false atom, and empty lists are considered true. In Ruby,

I'll inject a pedantic note: there is only one false value in both
Lisp (which now is mostly Common Lisp) and Scheme.

The empty list () and the symbol NIL in Lisp are one value, not two
values. The first Google hit (for me, just now) explains it the way I
understand it: <http://www.ida.liu.se/imported/cltl/clm/node9.html>.
(Common Lisp The Language, 2nd edition. Odd place to find that book.
It predates the formal standard, but then I think this particular
feature of the language is, indeed, as old as you say, and unlikely to
have changed.)

Scheme was the same. Then for a time it was not specified whether the
empty list was distinct from the false value or the symbol nil -
people disagreed and implementations were allowed to differ - until
the three were definitely separated.



More information about the Python-list mailing list