Article View: comp.lang.prolog
Article #5Re: Turbo Prolog Help
From: Arjen Duursma
Date: Wed, 28 Oct 1992 06:40
Date: Wed, 28 Oct 1992 06:40
34 lines
1562 bytes
1562 bytes
btoben@crappie.usd.edu (B. Toben) writes: >Hi - Hi back to you >I know precious little about prolog, but I have an assignment due in prolog >to solve a problem. I've gone to the instructor about it, but she doesn't >seem too concerned, so I was hoping for a little help. The problem is that >when I have a clause like > drives(mike,X) :- X <> "camaro". >I get an error if I state a goal like drives(mike,Z) because >Turbo Prolog says it has nothing to compare against "camaro". I understand ^^^^^^^^^^^^^ Include standard statements about Turbo Prolog not being prolog >why I get the error, but my question is, is there a way around it, using that >general logic? I don't know about Turbo Prolog but in normal prolog you would say: drives(mike,X) :- '\+'(X = 'camaro'). or drives(mike,camaro) :- !,fail. drives(mike,_). Which would give no answers to you question. A better solution would be: drives(mike,X) :- car(X), X <> "camaro". /* if this is correct syntax */ This would ensure that mike is driving cars and X is instantiated before the test. Your query would result in listing all the cars except camaro upon backtracking. (ofcourse the predicate car/1 must be declared!) Arjen
Technical Details
Message-ID:
<596@tower1.uucp>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!disnet!arjenReferences:
<Bwr5A0.2Kr@sunfish.usd.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!disnet!arjen From: arjen@disnet.uucp (Arjen Duursma) Newsgroups: comp.lang.prolog Subject: Re: Turbo Prolog Help Message-ID: <596@tower1.uucp> Date: 28 Oct 92 06:40:17 GMT References: <Bwr5A0.2Kr@sunfish.usd.edu> Organization: Disnet, IDE Maassluis, The Netherlands Lines: 34