Jump to content

Comma quibbling: Difference between revisions

Added Wren
m (→‎{{header|Ruby}}: Fix link: Perl 6 --> Raku)
(Added Wren)
Line 3,673:
{ABC, DEF, G and H}
{ABC, DEF, G and H}</pre>
 
=={{header|Wren}}==
<lang ecmascript>var quibbling = Fn.new { |w|
var c = w.count
if (c == 0) return "{}"
if (c == 1) return "{%(w[0])}"
if (c == 2) return "{%(w[0]) and %(w[1])}"
return "{%(w[0..-2].join(", ")) and %(w[-1])}"
}
 
var words = [ [], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"] ]
for (w in words) System.print(quibbling.call(w))</lang>
 
{{out}}
<pre>
{}
{ABC}
{ABC and DEF}
{ABC, DEF, G and H}
</pre>
 
=={{header|XLISP}}==
9,490

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.