RosettaCodeData/Task/Singly-linked-list-Element-.../Pluto/singly-linked-list-element-...

9 lines
202 B
Plaintext

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