??ANSWER TO EXERCISE 53

Class Letter
  with list_together
       [;  if (inventory_stage==1)
           {   print "the letters ";
               if (~~(c_style & ENGLISH_BIT))   c_style = c_style + ENGLISH_BIT;
               if (~~(c_style & NOARTICLE_BIT)) c_style = c_style + NOARTICLE_BIT;
               if (c_style & NEWLINE_BIT)       c_style = c_style - NEWLINE_BIT;
               if (c_style & INDENT_BIT)        c_style = c_style - INDENT_BIT;
           }
           else print " from a Scrabble set";
       ],
       short_name
       [;  if (listing_together ofclass Letter) rfalse;
           print "letter ", (object) self, " from a Scrabble set"; rtrue;
       ],
       article "the";
and then as many letters as desired, along the lines of
Letter -> "X" with name "x";

Back to the exercise in section 23
Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright © Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.