def _accumulate(iterable, fn=(lambda x, y: (x + y))):
 it = iter(iterable)
 try:
  total = next(it)
 except StopIteration:
  return
 (yield total)
 for element in it:
  total = fn(total, element)
  (yield total)

def _accumulate ( iterable , fn = ( lambda x , y : ( x + y ) ) ) : it = iter ( iterable ) try : total = next ( it ) except StopIteration : return ( yield total ) for element in it : total = fn ( total , element ) ( yield total )
return running totals .