Created
January 1, 2016 19:16
-
-
Save ozgurkaracam/e3fb47b400c8ec1f897f to your computer and use it in GitHub Desktop.
pythonda halka sayıcı.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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