RosettaCodeData/Task/Comma-quibbling/Seed7/comma-quibbling.seed7
2023-07-01 13:44:08 -04:00

21 lines
613 B
Text

$ include "seed7_05.s7i";
const func string: quibble (in array string: input) is func
result
var string: quibble is "{";
begin
case length(input) of
when {0}: quibble &:= "}";
when {1}: quibble &:= input[1] & "}";
otherwise: quibble &:= join(input[.. pred(length(input))], ", ") &
" and " & input[length(input)] & "}";
end case;
end func;
const proc: main is func
begin
writeln(quibble(0 times ""));
writeln(quibble([] ("ABC")));
writeln(quibble([] ("ABC", "DEF")));
writeln(quibble([] ("ABC", "DEF", "G", "H")));
end func;