RosettaCodeData/Task/Comma-quibbling/Tcl/comma-quibbling.tcl
2015-02-20 09:02:09 -05:00

7 lines
221 B
Tcl

proc commaQuibble {lst} {
return \{[join [lreplace $lst end-1 end [join [lrange $lst end-1 end] " and "]] ", "]\}
}
foreach input { {} {"ABC"} {"ABC" "DEF"} {"ABC" "DEF" "G" "H"} } {
puts [commaQuibble $input]
}