On Wed, Nov 26, 2014 at 8:56 AM, random832@fastmail.us wrote:
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