21 lines
283 B
Plaintext
21 lines
283 B
Plaintext
|
class Buffer
|
||
|
new: (limit = 5) =>
|
||
|
@limit = limit
|
||
|
@data = {}
|
||
|
|
||
|
add: (line) =>
|
||
|
if #data == @limit
|
||
|
table.remove @data, 0
|
||
|
|
||
|
table.insert @data, line
|
||
|
|
||
|
b = Buffer!
|
||
|
while true
|
||
|
n = io.read!
|
||
|
if n ~= nil
|
||
|
b\add(n)
|
||
|
else break
|
||
|
|
||
|
for _, i in pairs b\data
|
||
|
print i
|