home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pop / 36 next >
Encoding:
Text File  |  1992-11-15  |  1.3 KB  |  58 lines

  1. Newsgroups: comp.lang.pop
  2. Path: sparky!uunet!deshaw.com!jcl
  3. From: jcl@deshaw.com (Jonathan Laventhol)
  4. Subject: Re: A little Pop history
  5. Message-ID: <BxrLG6.2v4@deshaw.com>
  6. Sender: usenet@deshaw.com
  7. Nntp-Posting-Host: fs2
  8. Organization: D. E. Shaw & Co.
  9. References: <Bxpqvt.Lq@deshaw.com> <1e3bt3INNjc9@agate.berkeley.edu>
  10. Date: Sun, 15 Nov 1992 15:52:54 GMT
  11. Lines: 45
  12.  
  13. Hi --
  14.  
  15. Yep, of course, Brian was right and saw my bug.  Well, here's
  16. the fixings.
  17.  
  18.     define recursivemember(item, list);
  19.     var item, list, element;
  20.         if list = [] then
  21.             return(false)
  22.         endif;
  23.  
  24.         for el in list do
  25.             if el = item then
  26.                 return(true)
  27.             elseif islist(el) and recursivemember(item, el) then
  28.                 return(true);
  29.             endif
  30.         endfor;
  31.  
  32.         return(false);
  33.     enddefine;
  34.  
  35. This illustrates another facet of the language: that boolean
  36. expression evaluation is defined to be ordered (left to right), as is
  37. argument evaluation.
  38.  
  39. Sorry/thanks.
  40. J.
  41.  
  42.  
  43. bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:
  44.  
  45. >jcl@deshaw.com (Jonathan Laventhol) writes:
  46. [...]
  47. >|        for el in list do
  48. >|            if el = item then
  49. >|                return(true)
  50. >|            elseif islist(el) then
  51. >|                return(recursivemember(item, el));
  52. >|            endif
  53. >|        endfor;
  54. [...]
  55. >Can this be right?  It looks to me as if it'll say that X isn't
  56. >a recursivemember of [[A B C] [X Y Z]] because it isn't in the
  57. >first sublist.
  58.