Implement a fucked tail
This commit is contained in:
parent
be18a0a148
commit
65c265cb62
|
@ -0,0 +1,20 @@
|
|||
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
|
Loading…
Reference in New Issue