A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-August/028391.html below:

PEP 218 (sets); moving set.py to Lib]

[Python-Dev] A `cogen' module [was: Re: PEP 218 (sets); moving set.py to Lib] [Python-Dev] A `cogen' module [was: Re: PEP 218 (sets); moving set.py to Lib]Guido van Rossum guido@python.org
Wed, 28 Aug 2002 11:02:25 -0400
> Even if all the arguments are re-iterable containers the recursive call
> produces a lazy generator object - the cartesian product of the tail. I 
> don't want to read it eagerly into a list.

And I wasn't proposing that.

def cartesian(*sequences):
    if len(sequences) == 0:
        yield []
    else:
        head, tail = sequences[:-1], sequences[-1]
        tail = list(tail) # <--- This is what I was proposing
        for x in cartesian(*head):
            for y in tail:
                    yield x + [y]

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4