Skip to content

Instantly share code, notes, and snippets.

@ozgurkaracam
Created January 1, 2016 19:16
Show Gist options
  • Save ozgurkaracam/e3fb47b400c8ec1f897f to your computer and use it in GitHub Desktop.
Save ozgurkaracam/e3fb47b400c8ec1f897f to your computer and use it in GitHub Desktop.
pythonda halka sayıcı.
#halka sayıcı
#özgür karaçam
class RingBuffer:
def __init__(self,s):
self.size=s
self.items=s*[None]
def append(self,a):
self.items.append(a)
def get(self):
return self.items[-4:]
buf = RingBuffer(4)
for i in range (10):
buf.append(i)
print (buf.get())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment