Skip to content

Instantly share code, notes, and snippets.

@robinsonkwame
Created October 14, 2016 17:15
Show Gist options
  • Save robinsonkwame/b618bd1ba69463e9bdf9456653565811 to your computer and use it in GitHub Desktop.
Save robinsonkwame/b618bd1ba69463e9bdf9456653565811 to your computer and use it in GitHub Desktop.
from itertools import chain, repeat
from six.moves import reduce
def reducer(accum_value, x):
return tuple(sum(t) for t in zip(accum_value, x + (1,)))
k = (item for item in ((3,4),(4,66),(100,4)))
start = next(k)+(1,)
t = reduce(reducer, k, start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment