27 lines
570 B
Text
27 lines
570 B
Text
program comma_quibbling;
|
|
tests := [
|
|
[],
|
|
["ABC"],
|
|
["ABC","DEF"],
|
|
["ABC","DEF","G","H"]
|
|
];
|
|
|
|
loop for t in tests do
|
|
print(t, "=", quibble(t));
|
|
end loop;
|
|
|
|
proc quibble(words);
|
|
ret := '{';
|
|
loop while words /= [] do
|
|
word fromb words;
|
|
ret +:= word;
|
|
case of
|
|
(#words = 1):
|
|
ret +:= " and ";
|
|
(#words > 1):
|
|
ret +:= ", ";
|
|
end case;
|
|
end loop;
|
|
return ret + '}';
|
|
end proc;
|
|
end program;
|