Comma quibbling: Difference between revisions
Content added Content deleted
(Added Easylang) |
Not a robot (talk | contribs) (add SETL) |
||
Line 4,291: | Line 4,291: | ||
{ABC, DEF, G and H} |
{ABC, DEF, G and H} |
||
</pre> |
</pre> |
||
=={{header|SETL}}== |
|||
<syntaxhighlight lang="setl">program comma_quibbling; |
|||
tests := [ |
|||
[], |
|||
["ABC"], |
|||
["ABC","DEF"], |
|||
["ABC","DEF","G","H"] |
|||
]; |
|||
loop for t in tests do |
|||
print(t, "=", quibble(t)); |
|||
end loop; |
|||
proc quibble(words); |
|||
ret := '{'; |
|||
loop while words /= [] do |
|||
word fromb words; |
|||
ret +:= word; |
|||
case of |
|||
(#words = 1): |
|||
ret +:= " and "; |
|||
(#words > 1): |
|||
ret +:= ", "; |
|||
end case; |
|||
end loop; |
|||
return ret + '}'; |
|||
end proc; |
|||
end program;</syntaxhighlight> |
|||
{{out}} |
|||
<pre>[] = {} |
|||
[ABC] = {ABC} |
|||
[ABC DEF] = {ABC and DEF} |
|||
[ABC DEF G H] = {ABC, DEF, G and H}</pre> |
|||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
<syntaxhighlight lang="ruby">func comma_quibbling(words) { |
<syntaxhighlight lang="ruby">func comma_quibbling(words) { |