RosettaCodeData/Task/Stack/Lingo/stack.lingo
2023-07-01 13:44:08 -04:00

23 lines
341 B
Text

-- 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