home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / icon / 534 < prev    next >
Encoding:
Text File  |  1992-11-20  |  929 b   |  38 lines

  1. Newsgroups: comp.lang.icon
  2. Path: sparky!uunet!mercury.hsi.com!mlfarm!cs.arizona.edu!icon-group
  3. Date: Fri, 20 Nov 92 12:48:54 EST
  4. From: Paul_Abrahams@MTS.cc.Wayne.edu
  5. Message-ID: <530200@MTS.cc.Wayne.edu>
  6. Subject: Scanning a list of items
  7. Lines: 29
  8.  
  9. The Icon Analyst #15 describes several versions of code to scan and
  10. process a list of items.  The list has the form of a string with markers
  11. between items but without a marker after the last item.  An unattractive
  12. solution is
  13.  
  14. text ||:= marker
  15. text ? {
  16.    while process(tab(find(marker))) do
  17.       =marker
  18.    }
  19. A better solution suggested by the Analyst is
  20.  
  21. text ? {
  22.    while process(tab(find(marker)|0)) do
  23.       =marker | break
  24.    }
  25.  
  26. But here's another alternative, which is what I've usually done:
  27.  
  28. (text || marker) ? {
  29.    while process(tab(find(marker))) do
  30.       =marker
  31.    }
  32.  
  33. As to which of the alternatives is better, de gustibus non est
  34. disputandum.
  35.  
  36. Paul Abrahams
  37.  
  38.