home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.icon
- Path: sparky!uunet!mercury.hsi.com!mlfarm!cs.arizona.edu!icon-group
- Date: Fri, 20 Nov 92 12:48:54 EST
- From: Paul_Abrahams@MTS.cc.Wayne.edu
- Message-ID: <530200@MTS.cc.Wayne.edu>
- Subject: Scanning a list of items
- Lines: 29
-
- The Icon Analyst #15 describes several versions of code to scan and
- process a list of items. The list has the form of a string with markers
- between items but without a marker after the last item. An unattractive
- solution is
-
- text ||:= marker
- text ? {
- while process(tab(find(marker))) do
- =marker
- }
- A better solution suggested by the Analyst is
-
- text ? {
- while process(tab(find(marker)|0)) do
- =marker | break
- }
-
- But here's another alternative, which is what I've usually done:
-
- (text || marker) ? {
- while process(tab(find(marker))) do
- =marker
- }
-
- As to which of the alternatives is better, de gustibus non est
- disputandum.
-
- Paul Abrahams
-
-