Comma quibbling: Difference between revisions

no edit summary
(Added R.)
No edit summary
Line 4,169:
{ABC and DEF}
{ABC, DEF, G and H}
</pre>
 
=={{header|XBS}}==
<lang>func task(a:array){
set x:string="";
foreach(k,v as a){
set out:string="";
if ((k==(?a-2))&((?a)>1)){out=" and "}elif(k!=(?a-1)){out=", "}
x+=v+out;del out;
}
send "{"+x+"}";
}
 
log(task([]));
log(task(["ABC"]));
log(task(["ABC","DEF"]));
log(task(["ABC","DEF","GHI"]));</lang>
{{out}}
<pre>
{}
{ABC}
{ABC and DEF}
{ABC, DEF and GHI}
</pre>
 
Anonymous user