RosettaCodeData/Task/Singly-linked-list-Element-insertion/Pluto/singly-linked-list-element-insertion.pluto
2025-08-11 18:05:26 -07:00

8 lines
202 B
Text

require "list"
local s = slist.of("A", "B")
local ixs = s:find("A") -- always returns an array of indices even if we only want the first
if #ixs > 0 then
s:insert(ixs[1] + 1, "C")
print(s)
end