iterators and views of lists
Anh Hai Trinh
anh.hai.trinh at gmail.com
Sun Dec 20 01:18:43 EST 2009
On Dec 20, 12:04 am, Anh Hai Trinh <anh.hai.tr... at gmail.com> wrote:
> chain:
>
> sorted(itertools.chain(listagent(x)[::2], listagent(y)[-1:1:-2]))
> [0, 4, 8, 12, 13, 15, 16, 17, 19]
>
> zip:
>
> sorted(itertools.izip(listagent(z)[1::3], listagent(x)[2::3]))
> [(452, 16), (758, 4), (898, 10)]
I think I mis-interpret Andrei's slides. I think what he meant to sort
a chain of slices is such that to move the smaller elements into the
first-given slices in-place, thus moving items around whatever lists
underlying those slices.
And for zip, I think he meant sort the first slice, but moving in-
place the items referred by the others in lock-step.
More information about the Python-list
mailing list