RosettaCodeData/Task/Comma-quibbling/Phix/comma-quibbling.phix
2017-09-25 22:28:19 +02:00

15 lines
360 B
Text

function quibble(sequence words)
if length(words)>=2 then
words[-2..-1] = {words[-2]&" and "&words[-1]}
end if
return "{"&join(words,", ")&"}"
end function
constant tests = {{},
{"ABC"},
{"ABC","DEF"},
{"ABC","DEF","G","H"}}
for i=1 to length(tests) do
?quibble(tests[i])
end for