Comma quibbling: Difference between revisions

Content deleted Content added
Removed one useless constraint from the task description.
Grondilu (talk | contribs)
No edit summary
Line 39: Line 39:
{ABC and DEF}
{ABC and DEF}
{ABC, DEF, G and H}</pre>
{ABC, DEF, G and H}</pre>

=={{header|Perl 6}}==
<lang perl6>sub comma-quibbling(@A) {
'{' ~ (
@$_ < 3 ?? .join(',') !!
.[0..*-2].join(',') ~ ' and ' ~ .[*-1]
) ~ '}' given @A».perl
}

say comma-quibbling(eval($_)) for
< [] ["ABC"] ["ABC","DEF"] ["ABC","DEF","G","H"] >;</lang>
{{out}}
<pre>{}
{"ABC"}
{"ABC","DEF"}
{"ABC","DEF","G" and "H"}</pre>


=={{header|Python}}==
=={{header|Python}}==