home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / lisp / 2922 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.6 KB  |  43 lines

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!europa.asd.contel.com!awds.imsd.contel.com!llyene!jato!ufo!Aig.Jpl.Nasa.Gov!charest
  3. From: charest@Aig.Jpl.Nasa.Gov (Len Charest)
  4. Subject: Re: Elegant control structure wanted
  5. Message-ID: <1992Nov19.223154.4885@jpl-devvax.jpl.nasa.gov>
  6. Sender: usenet@jpl-devvax.jpl.nasa.gov (For NNTP so rrn will be able to post)
  7. Nntp-Posting-Host: ai-cyclops
  8. Reply-To: charest@aig.jpl.nasa.gov
  9. Organization: NASA/Jet Propulsion Laboratory
  10. References:  <98373@netnews.upenn.edu>
  11. Date: Thu, 19 Nov 1992 22:31:54 GMT
  12. Lines: 29
  13.  
  14. In article <98373@netnews.upenn.edu>, zaidel@muzungu.cis.upenn.edu (Martin J. Zaidel) writes:
  15. |> I've written an equality predicate to test two structures.  My
  16. |> predicate is of the form:
  17.  
  18. |> (defun node-equal (node1 node2)
  19. |>    (and (if (slot1-equal slot1 slot2) 
  20. |>         t
  21. |>         (format t "Slot 1 not equal"))
  22. |>     (if (slot2-equal slot1 slot2)
  23. |>         t
  24. |>         (format t "Slot 2 not equal"))
  25. |>     (if (slot3-equal slot1 slot2)
  26. |>         t
  27. |>         (format t "Slot 3 not equal"))))
  28. |> 
  29. |> This explicit use of T for the value of the IF strikes me as rather
  30. |> inelegant.  I'd appreciate suggestions for a nicer solution.
  31.  
  32. Did you mean to write 'node1' and 'node2' instead of 'slot1' and 'slot2'?
  33. Relying on the fact that FORMAT returns NIL:
  34.  
  35. (defun node-equal (node1 node2)
  36.   (and (or (slot1-equal node1 node2)
  37.            (format t "..."))
  38.        ...and so on ))
  39. ..................................................
  40.                                   Len Charest, Jr.
  41.                  JPL Artificial Intelligence Group
  42.                           charest@aig.jpl.nasa.gov
  43.