Anonymous user
Comma quibbling: Difference between revisions
no edit summary
(→{{header|Perl 6}}: no need to use a string input actually) |
No edit summary |
||
Line 70:
Input: ['ABC', 'DEF'] -> Output: '{ABC and DEF}'
Input: ['ABC', 'DEF', 'G', 'H'] -> Output: '{ABC, DEF, G and H}'
>>> </lang>
=={{header|Rexx}}==
<lang Rexx>>>>
say quibbling('ABC')
say quibbling('ABC DEF')
say quibbling('ABC DEF G H')
exit
quibbling: procedure
parse arg list
if words(list) < 2 then return list
return translate(strip(subword(list,1,words(list)-1)),',',' ') 'and' word(list,words(list))
Output:
ABC
ABC and DEF
ABC,DEF,G and H
>>> </lang>
|