Skip to content

Commit

Permalink
Remove needless nesting on Stack
Browse files Browse the repository at this point in the history
  • Loading branch information
ojv committed Mar 6, 2017
1 parent 101159d commit 24485b8
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,26 @@ local function Set(t) -- {{{3
end

local function Stack() -- {{{3
return (function()
local stack = {}
local head = 0
return {
head = function()
return stack[head]
end,

push = function(e)
head = head + 1
stack[head] = e
end,

pop = function()
if head == 0 then return nil end
local e = stack[head]
stack[head] = nil
head = head - 1
return e
end
}
end)()
local stack = {}
local head = 0
return {
head = function()
return stack[head]
end,

push = function(e)
head = head + 1
stack[head] = e
end,

pop = function()
if head == 0 then return nil end
local e = stack[head]
stack[head] = nil
head = head - 1
return e
end
}
end

-- MODULES -- {{{2
Expand Down

0 comments on commit 24485b8

Please sign in to comment.