RosettaCodeData/Task/Stack/Lingo/stack.lingo

24 lines
341 B
Text
Raw Permalink Normal View History

2016-12-05 23:44:36 +01:00
-- 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