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

18 lines
305 B
AutoHotkey

MsgBox % quibble([])
MsgBox % quibble(["ABC"])
MsgBox % quibble(["ABC", "DEF"])
MsgBox % quibble(["ABC", "DEF", "G", "H"])
quibble(d) {
s:=""
for i, e in d
{
if (i<d.MaxIndex()-1)
s:= s . e . ", "
else if (i=d.MaxIndex()-1)
s:= s . e . " and "
else
s:= s . e
}
return "{" . s . "}"
}