Semantics of ==

Fred Mailhot fred.mailhot at videotron.ca
Tue Mar 30 17:22:39 EST 2004


On 3/29/04 4:26 AM, "Axel Boldt" <axelboldt at yahoo.com> wrote:

[snip]

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

Seems to me that the example given makes it clear that l is not
well-founded. Look at it step by step:

(1) >>> l = []

at this stage, l is *not* well-founded, since it's a list with no elements,
and the definition explicitly states that a well-founded list is a list
containing all and only well-founded elements, and the only thing other than
lists that can be well-founded are strings and numbers.

(2) >>> l.append(l)

at this stage, l is *still* not well-founded, since all it contains is a
list that we've already seen is not well-founded (cf. the original
definition)...


Fred.




More information about the Python-list mailing list