cleaning up

This commit is contained in:
leaf corcoran 2013-12-30 01:43:25 -08:00
parent dd1a06ff1a
commit 23a99aa365
2 changed files with 21 additions and 23 deletions

View File

@ -5,12 +5,12 @@ do
end
local Set
Set = function(items)
local self = { }
local _tbl_0 = { }
for _index_0 = 1, #items do
local key = items[_index_0]
self[key] = true
local k = items[_index_0]
_tbl_0[k] = true
end
return self
return _tbl_0
end
local Stack
do
@ -21,9 +21,13 @@ do
pop = function(self)
return remove(self)
end,
push = function(self, value)
push = function(self, value, ...)
insert(self, value)
if ... then
return self:push(...)
else
return value
end
end,
top = function(self)
return self[#self]
@ -32,13 +36,7 @@ do
_base_0.__index = _base_0
local _class_0 = setmetatable({
__init = function(self, ...)
local _list_0 = {
...
}
for _index_0 = 1, #_list_0 do
local v = _list_0[_index_0]
self:push(v)
end
self:push(...)
return nil
end,
__base = _base_0,

View File

@ -2,30 +2,30 @@
import concat, remove, insert from table
Set = (items) ->
self = {}
self[key] = true for key in *items
self
Set = (items) -> {k,true for k in *items}
class Stack
__tostring: => "<Stack {"..concat(self, ", ").."}>"
new: (...) =>
@push v for v in *{...}
@push ...
nil
pop: =>
remove self
remove @
push: (value) =>
insert self, value
push: (value, ...) =>
insert @, value
if ...
@push ...
else
value
top: =>
self[#self]
lua_keywords = Set{
lua_keywords = Set {
'and', 'break', 'do', 'else', 'elseif',
'end', 'false', 'for', 'function', 'if',
'in', 'local', 'nil', 'not', 'or',