[Python-Dev] PEP 201 - Parallel iteration
Ken Manheimer
klm@digicool.com
Mon, 17 Jul 2000 20:43:38 -0400 (EDT)
Whoops, i got my section wrong. Disregard the last part.
On Mon, 17 Jul 2000, Ken Manheimer wrote:
> On Tue, 18 Jul 2000, Peter Schneider-Kamp wrote:
>
> > One important remark:
> > What about unzip()? Shouldn't there be the reverse function?
> > One example (which I really wrote not so long ago in an ANN context):
>
> Evan Simpson (a colleague here at digicool, who'd be a good addition
> to python-dev) noticed that unzip is unnecessary - zip is its own
> inverse. Since this is a worthwhile observation, i'll indulge a bit
> and present it in evan's terms - particularly noting a different
> packaging that i think is pretty cool, as methods on sequences.
>
> > From evan@digicool.com Mon Jul 17 20:17:30 2000
> > Date: Mon, 17 Jul 2000 14:36:18 -0400
> > From: Evan Simpson <evan@digicool.com>
> > To: Ken Manheimer <klm@digicool.com>
> > Subject: Next Braid
> >
> > How's this:
> >
> > ([1, 2, 3], ['a', 'b', 'c']).braid() == ((1, 'a'), (2, 'b'), (3, 'c'))
> > [[1, 2, 3], ['a', 'b', 'c']].braid() == [(1, 'a'), (2, 'b'), (3, 'c')]
> >
> > and
> >
> > [[1,2,3], ['a']].braid(None) == [(1, 'a'), (2, None), (3, None)]
> >
> > Also, notice that if 's' is a rectangular sequence of sequences, then for
> > all 'a' and 'b':
> >
> > s.braid()[a][b] == s[b][a] by definition, so
> >
> > s.braid().braid()[a][b] == s.braid()[b][a] == s[a][b] and therefore,
> >
> > braid is its own inverse, and we don't need unbraid.
> >
> > Cheers,
> >
> > Evan @ digicool & 4-am
>
> I can't do better than that, but i have one further elaboration i'd
> like to see. If the subject sequence already contains some elements,
> the result sequence is a copy of the originals with the new braided,
> whoops zipped elements appended - this way, braids can be cumulative.
>
> >>> [(1, 3), (2, 4)].braid(('a', 'b'), ('x', 'y'))
> [(1, 3, 'a', 'x'), (2, 4, 'b', 'y')]
>
> Anyway, we don't need an unzip/unbraid. !
>
> Ken
> klm@digicool.com
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://www.python.org/mailman/listinfo/python-dev
>