RosettaCodeData/Task/Comma-quibbling/Pluto/comma-quibbling.pluto
2026-04-30 12:34:36 -04:00

10 lines
359 B
Text

local function quibbling(w)
local c = #w
if c == 0 then return "{}" end
if c == 1 then return $"\{{w[1]}}" end
if c == 2 then return $"\{{w[1]} and {w[2]}}" end
return $"\{{w:slice(1, #w - 1):concat(", ")} and {w[#w]}}"
end
local words = { {}, {"ABC"}, {"ABC", "DEF"}, {"ABC", "DEF", "G", "H"} }
for words as w do print(quibbling(w)) end