25 Nov
2014
25 Nov
'14
3:31 p.m.
On Wed, Nov 26, 2014 at 8:56 AM,
For something more concrete, we can consider a naive implementation of iteration over adjacent pairs:
def pairs(x): i = iter(x) while True: yield next(i), next(i)
Okay, it's simple and naive. How about this version: def pairs(x): i = iter(x) for val in i: yield val, next(i) Also simple, but subtly different from your version. What's the difference? Will it be obvious to everyone who reads it? ChrisA