Semantics of ==

Axel Boldt axelboldt at yahoo.com
Mon Mar 29 07:26:34 EST 2004


Erik Max Francis <max at alcyone.com> wrote
> Axel Boldt wrote:
> > Erik Max Francis <max at alcyone.com> wrote
> > 
> > > What part of the semantics are you unclear about?  Two sequences are
> > > equal if they are element-wise equal.
> > 
> > That definition is circular.
> 
> No, because presumably you already understand what equality means for
> two non-sequence objects.

Yes, but a list can contain other lists, and even itself, as elements.
So in order to understand what equality for lists means, according to
the above definition, you already need to understand what equality for
lists means. That's what makes the definition circular. I thought we
had clarified that much a week ago.

> > Consider for instance the following definition:
> > * all strings and numbers are called "well-founded"
> > * a list is called well-founded if and only if all its elements are
> > well-founded.
> > 
> > l=[]
> > l.append(l)
> > Is l well-founded? Both answers "yes" and "no" are consistent with the
> > above definition.
> 
> No they aren't, since l's first element is a list, not a string or
> number.

The above definition does not require that the first element of a
well-founded list be a string or number. It could also be a
well-founded list.

> What is the point of this definition?

To show how easy it is to give circular definitions (and
non-terminating recursive functions) when dealing with lists.

Axel



More information about the Python-list mailing list