Skip to content

Instantly share code, notes, and snippets.

@partkyle
Created February 26, 2013 21:46
Show Gist options
  • Save partkyle/5042534 to your computer and use it in GitHub Desktop.
Save partkyle/5042534 to your computer and use it in GitHub Desktop.
def running_avg():
total = float((yield))
count = 1
while True:
total += yield total / count
count += 1
avg = running_avg()
avg.next()
print avg.send(10)
print avg.send(0)
print avg.send(1)
print avg.send(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment