home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.prolog
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!Sirius.dfn.de!chx400!bernina!neptune!nugget.inf.ethz.ch!marti
- From: marti@nugget.inf.ethz.ch (Robert Marti)
- Subject: Re: Help on problem needed!
- Message-ID: <1992Aug26.130909.17909@neptune.inf.ethz.ch>
- Keywords: help
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Nntp-Posting-Host: nugget.inf.ethz.ch
- Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
- References: <meskes.713709771@ulysses> <1992Aug25.074623.25450@greco-prog.fr>
- Date: Wed, 26 Aug 1992 13:09:09 GMT
- Lines: 31
-
- In article <1992Aug25.074623.25450@greco-prog.fr>, billaud@greco-prog.fr
- (Michel BILLAUD) writes:
- |> In article <meskes.713709771@ulysses>
- |> meskes@ulysses.informatik.rwth-aachen.de (Michael Meskes) writes:
- |>
- |> > Can you program a IF...THEN...ELSE in Prolog without using the cut?
- |>
- |> No. a proof by contradiction:
-
- [ proof deleted ]
-
- I am sorry to contradict your contradiction ;-) As someone else has
- pointed out, it _is_ possible to program if-then-else without cut
- IN CERTAIN SPECIAL CASES.
-
- Canonical example:
- IF X >= Y THEN Max := X ELSE Max := Y END
-
- Prolog translation:
- % max(+X,+Y,?Max): Max is the maximum of X and Y
- max(X,Y,X) :- X >= Y.
- max(X,Y,Y) :- X < Y.
-
- This works because < happens to be the logical negation of >=
- provided that both arguments are ground.
-
- --
- Robert Marti | Phone: +41 1 254 72 60
- Informationssysteme | FAX: +41 1 262 39 73
- ETH-Zentrum | E-Mail: marti@inf.ethz.ch
- CH-8092 Zurich, Switzerland |
-