Comma quibbling: Difference between revisions
Content deleted Content added
Not a robot (talk | contribs) Add CLU |
|||
Line 1,100: | Line 1,100: | ||
{ABC, DEF, G and H} |
{ABC, DEF, G and H} |
||
</pre> |
</pre> |
||
=={{header|CLU}}== |
|||
<lang clu>quibble = proc (words: array[string]) returns (string) |
|||
out: string := "{" |
|||
last: int := array[string]$high(words) |
|||
for i: int in array[string]$indexes(words) do |
|||
out := out || words[i] |
|||
if i < last-1 then |
|||
out := out || ", " |
|||
elseif i = last-1 then |
|||
out := out || " and " |
|||
end |
|||
end |
|||
return(out || "}") |
|||
end quibble |
|||
start_up = proc () |
|||
as = array[string] |
|||
aas = array[as] |
|||
po: stream := stream$primary_output() |
|||
testcases: aas := aas$ |
|||
[as$[], |
|||
as$["ABC"], |
|||
as$["ABC","DEF"], |
|||
as$["ABC","DEF","G","H"]] |
|||
for testcase: as in aas$elements(testcases) do |
|||
stream$putl(po, quibble(testcase)) |
|||
end |
|||
end start_up</lang> |
|||
{{out}} |
|||
<pre>{} |
|||
{ABC} |
|||
{ABC and DEF} |
|||
{ABC, DEF, G and H}</pre> |
|||
=={{header|COBOL}}== |
=={{header|COBOL}}== |