Comma quibbling: Difference between revisions
Content deleted Content added
→{{header|ALGOL 68}}: corrected case of "AND" |
→{{header|ALGOL W}}: Use a function procedure and corrected case of "AND" |
||
Line 135:
<lang algolw>begin
%
% except for the last which is separated from the rest by "
% The words are enclosed by braces %
string(256) procedure toList ( string(256) value words ) ;
; string(256) result list▼
begin
integer wordCount, wordNumber, listPos;
logical inWord;
Line 207 ⟶ 206:
if wordNumber > 1 then begin
% second or subsequent word - need a separator %
if wordNumber = wordCount then addString( "
else addString( ", ", 2 ) % non-final word %
end
Line 218 ⟶ 217:
addChar( "}" );
list
end toList ;
% procedure to test the toList
procedure testToList ( string(256) value words ) ;
begin
string(256) list;
list := toList( words
write( s_w := 0
, words( 0 // 32 )
Line 244:
: {}
ABC : {ABC}
ABC DEF : {ABC
ABC DEF G H : {ABC, DEF, G
</pre>
|