PEP 276 Simple Iterator for ints (fwd)
David Eppstein
eppstein at ics.uci.edu
Wed Nov 28 19:30:26 EST 2001
In article <9u3uqu$bvfku$1 at fido.engr.sgi.com>, pj at sgi.com (Paul Jackson)
wrote:
> Greg wrote:
> > ... unless "i in 5" on its own were valid and
> > had a rather unintuitive meaning.
>
> But "i in 5" does have exactly the meaning needed here,
> for:
> 0 is the nul set
> 1 is the set containing 0
> 2 is the set containing 0 and 1
> ...
> 5 is the set containing 0 through 4
> ...
> n is the set containing 0 through n-1.
>
> Well ... to the 3 dozen people on the planet who majored
> in set theory this is all quite intuitive.
Well, except that this is only valid over the domain of natural numbers.
Here we are talking about integers not naturals.
I don't know how your set theory class defined the integers, but one
possible way is equivalence classes of ordered pairs (a,b) (representing
integers a-b) where a and b are naturals and (a,b) equiv (c,d) when
a+d=b+c. And then you have to worry about the set-theoretic definition of
ordered pairs...but it seems unlikely that you will choose a representation
for which "i in 5" really does have the meaning discussed here.
--
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list