RosettaCodeData/Task/Doubly-linked-list-Definition/Pluto/doubly-linked-list-definition.pluto
2025-08-11 18:05:26 -07:00

18 lines
330 B
Text

require "list"
local d = dlist.of("A", "B")
print(d)
-- Add an element at the head.
d:prepend("C")
-- Add an element in the middle.
d:insert(2, "D")
-- Add an element at the tail.
d:push("E")
print(d)
-- Remove an element by index (indexing is 1 based).
d:remove(2)
print(d)
-- Remove an element by value.
d:erase("A")
print(d)