Comma quibbling: Difference between revisions

Content added Content deleted
(Add Miranda)
(updated solution for Arturo)
Line 735: Line 735:


=={{header|Arturo}}==
=={{header|Arturo}}==
<syntaxhighlight lang="rebol">quibble: function [seq][
<syntaxhighlight lang="rebol">quibble: $[sequence :block][
if? 0=size seq -> "{}"
if? 0 = size sequence
-> return "{}"
else [
if? 1=size seq -> "{" ++ seq\0 ++ "}"
if? 1 = size sequence
else -> "{" ++ (join.with:", " slice seq 0 (size seq)-1) ++ " and " ++ (last seq) ++ "}"
-> return ~"{|sequence\0|}"
]
last: pop 'sequence
return ~« {|join.with: ", " sequence| and |last|}
]
]


Line 758: Line 761:
<pre>{}
<pre>{}
{ABC}
{ABC}
{ABC, DEF and DEF}
{ABC and DEF}
{ABC, DEF, G, H and H}</pre>
{ABC, DEF, G and H}</pre>


=={{header|Astro}}==
=={{header|Astro}}==