home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.lisp
- Path: sparky!uunet!europa.asd.contel.com!awds.imsd.contel.com!llyene!jato!ufo!Aig.Jpl.Nasa.Gov!charest
- From: charest@Aig.Jpl.Nasa.Gov (Len Charest)
- Subject: Re: Elegant control structure wanted
- Message-ID: <1992Nov19.223154.4885@jpl-devvax.jpl.nasa.gov>
- Sender: usenet@jpl-devvax.jpl.nasa.gov (For NNTP so rrn will be able to post)
- Nntp-Posting-Host: ai-cyclops
- Reply-To: charest@aig.jpl.nasa.gov
- Organization: NASA/Jet Propulsion Laboratory
- References: <98373@netnews.upenn.edu>
- Date: Thu, 19 Nov 1992 22:31:54 GMT
- Lines: 29
-
- In article <98373@netnews.upenn.edu>, zaidel@muzungu.cis.upenn.edu (Martin J. Zaidel) writes:
- |> I've written an equality predicate to test two structures. My
- |> predicate is of the form:
-
- |> (defun node-equal (node1 node2)
- |> (and (if (slot1-equal slot1 slot2)
- |> t
- |> (format t "Slot 1 not equal"))
- |> (if (slot2-equal slot1 slot2)
- |> t
- |> (format t "Slot 2 not equal"))
- |> (if (slot3-equal slot1 slot2)
- |> t
- |> (format t "Slot 3 not equal"))))
- |>
- |> This explicit use of T for the value of the IF strikes me as rather
- |> inelegant. I'd appreciate suggestions for a nicer solution.
-
- Did you mean to write 'node1' and 'node2' instead of 'slot1' and 'slot2'?
- Relying on the fact that FORMAT returns NIL:
-
- (defun node-equal (node1 node2)
- (and (or (slot1-equal node1 node2)
- (format t "..."))
- ...and so on ))
- ..................................................
- Len Charest, Jr.
- JPL Artificial Intelligence Group
- charest@aig.jpl.nasa.gov
-