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
 
% setsreturns a list toof the words contained in wordString, separated by ", ", %
% except for the last which is separated from the rest by " ANDand ". %
% The words are enclosed by braces %
string(256) procedure toList ( string(256) value words ) ;
; string(256) result list
) ;
begin
; string(256) result list;
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( " ANDand ", 5 ) % final word %
else addString( ", ", 2 ) % non-final word %
end
Line 218 ⟶ 217:
addChar( "}" );
 
list
end toList ;
 
 
% procedure to test the toList PROC procedure %
procedure testToList ( string(256) value words ) ;
begin
string(256) list;
list := toList( words, list );
write( s_w := 0
, words( 0 // 32 )
Line 244:
: {}
ABC : {ABC}
ABC DEF : {ABC ANDand DEF}
ABC DEF G H : {ABC, DEF, G ANDand H}
</pre>