workshit/src/moonscript/fuckedtail.moon

26 lines
356 B
Plaintext
Raw Normal View History

2015-06-15 23:04:33 +00:00
class Buffer
new: (limit = 5) =>
@limit = limit
@data = {}
2015-06-15 23:23:02 +00:00
purge: =>
if #@data > @limit
table.remove @data, 1
@purge!
else return
2015-06-15 23:04:33 +00:00
2015-06-15 23:23:02 +00:00
add: (line) =>
2015-06-15 23:04:33 +00:00
table.insert @data, line
2015-06-15 23:23:02 +00:00
@purge!
2015-06-15 23:04:33 +00:00
2015-06-15 23:23:02 +00:00
with Buffer 5
2015-06-15 23:13:57 +00:00
while true
n = io.read!
if n ~= nil
\add n
else
break
2015-06-15 23:04:33 +00:00
2015-06-15 23:13:57 +00:00
for _, i in pairs .data
print i