RosettaCodeData/Task/Stack/Lingo/stack.lingo

24 lines
341 B
Plaintext

-- parent script "Stack"
property _tos
on push (me, data)
me._tos = [#data:data, #next:me._tos]
end
on pop (me)
if voidP(me._tos) then return VOID
data = me._tos.data
me._tos = me._tos.next
return data
end
on peek (me)
if voidP(me._tos) then return VOID
return me._tos.data
end
on empty (me)
return voidP(me.peek())
end