RosettaCodeData/Task/Comma-quibbling/M2000-Interpreter/comma-quibbling-3.m2000
2023-07-01 13:44:08 -04:00

23 lines
622 B
Text

Module Checkit {
function f$(ar) {
flush
Data ! ar
m=stack.size
document resp$="{"
if m>2 then {
shift m-1, 2 ' get last two as first two
push letter$+" and "+letter$
m-- ' one less
shiftback m ' move to last position
}
while not empty {
resp$=letter$+if$(not empty->", ", "")
}
=resp$+"}"
}
? f$((,))
? f$(("ABC",))
? f$(("ABC", "DEF"))
? f$(("ABC","DEF", "G", "H"))
}
Checkit