what's wrong with this? 
Author Message
 what's wrong with this?

drink('Cola','soft drink').
drink('7_up','soft drink').
drink('white wine', 'light {*filter*}ic').
drink('red wine', 'light {*filter*}ic').
drink('Brandy', 'hard liquor').
drink('Whiskey', 'hard liquor').

min_age(18,'light {*filter*}ic').
min_age(21, 'hard liquor').

student('Pierre', 29).
student('John',   21).
student('Julie',  20).
student('Nancy',  17).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
legal(AName, ADrink) :- student(AName, Sage), drink(ADrink, AType),
min_age(Age, AType), Sage >= Age.

so if I do this:
?- legal('Pierre', 'Whiskey').  % this should print Yes
?- legal('Julie', 'Brandy'). % this should print No

Any help at all would be appreciated



Sat, 08 May 2004 21:33:19 GMT  
 what's wrong with this?

Quote:
> drink('Cola','soft drink').
> drink('7_up','soft drink').
> drink('white wine', 'light {*filter*}ic').
> drink('red wine', 'light {*filter*}ic').
> drink('Brandy', 'hard liquor').
> drink('Whiskey', 'hard liquor').

> min_age(18,'light {*filter*}ic').
> min_age(21, 'hard liquor').

> student('Pierre', 29).
> student('John',   21).
> student('Julie',  20).
> student('Nancy',  17).

> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> legal(AName, ADrink) :- student(AName, Sage), drink(ADrink, AType),
> min_age(Age, AType), Sage >= Age.

> so if I do this:
> ?- legal('Pierre', 'Whiskey').  % this should print Yes
> ?- legal('Julie', 'Brandy'). % this should print No

> Any help at all would be appreciated

Colin

There's nothing wrong with your program, it must be your Prolog.

--
Regards

John Fletcher



Sat, 08 May 2004 22:00:00 GMT  
 what's wrong with this?
thanks John, I was starting to go mad!

is there anything wrong with SWI - prolog? that's what I'm using

Quote:

> There's nothing wrong with your program, it must be your Prolog.

--

       home: http://nexus.carleton.ca/~colin/
 public key: http://nexus.carleton.ca/~colin/pubkey.asc
fingerprint: 1AD0 91ED B77A CC2B 87B1  4E51 012B 4BD2 8DC9 D62C



Sat, 08 May 2004 22:27:01 GMT  
 what's wrong with this?

Quote:
> thanks John, I was starting to go mad!

> is there anything wrong with SWI - prolog? that's what I'm using

<snipped>

Colin

I've just tried your program on SWI (Win2k) ...

Welcome to SWI-Prolog (Version 4.0.9)
Copyright (c) 1990-2000 University of Amsterdam.
Copy policy: GPL-2 (see www.gnu.org)

For help, use ?- help(Topic). or ?- apropos(Word).

1 ?- [user].
|: drink('Cola','soft drink').
|: drink('7_up','soft drink').
|: drink('white wine', 'light {*filter*}ic').
|: drink('red wine', 'light {*filter*}ic').
|: drink('Brandy', 'hard liquor').
|: drink('Whiskey', 'hard liquor').
|:
|: min_age(18,'light {*filter*}ic').
|: min_age(21, 'hard liquor').
|:
|: student('Pierre', 29).
|: student('John',   21).
|: student('Julie',  20).
|: student('Nancy',  17).
|:
|: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|: legal(AName, ADrink) :- student(AName, Sage), drink(ADrink, AType),
|: min_age(Age, AType), Sage >= Age.
|: end_of_file.
% user compiled 0.00 sec, 60,860 bytes

Yes
2 ?- legal('Pierre', 'Whiskey').

Yes
3 ?- legal('Julie', 'Brandy').

No

So I'm at a loss to explain it.

--
Regards

John Fletcher



Sat, 08 May 2004 23:41:26 GMT  
 what's wrong with this?
I was using version 3.4.x on linux i386.  I just upgraded to 4.0.10

and it works for me now.

thanks extremely very much!!  this assignment is due in less than 2 hours!

colin

Quote:

> I've just tried your program on SWI (Win2k) ...
> Welcome to SWI-Prolog (Version 4.0.9)
> Copyright (c) 1990-2000 University of Amsterdam.
> Copy policy: GPL-2 (see www.gnu.org)
> For help, use ?- help(Topic). or ?- apropos(Word).
> 1 ?- [user].
> |: drink('Cola','soft drink').
> |: drink('7_up','soft drink').
> |: drink('white wine', 'light {*filter*}ic').
> |: drink('red wine', 'light {*filter*}ic').
> |: drink('Brandy', 'hard liquor').
> |: drink('Whiskey', 'hard liquor').
> |:
> |: min_age(18,'light {*filter*}ic').
> |: min_age(21, 'hard liquor').
> |:
> |: student('Pierre', 29).
> |: student('John',   21).
> |: student('Julie',  20).
> |: student('Nancy',  17).
> |:
> |: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> |: legal(AName, ADrink) :- student(AName, Sage), drink(ADrink, AType),
> |: min_age(Age, AType), Sage >= Age.
> |: end_of_file.
> % user compiled 0.00 sec, 60,860 bytes
> Yes
> 2 ?- legal('Pierre', 'Whiskey').
> Yes
> 3 ?- legal('Julie', 'Brandy').
> No
> So I'm at a loss to explain it.
> --
> Regards
> John Fletcher

--

       home: http://www.*-*-*.com/ ~colin/
 public key: http://www.*-*-*.com/ ~colin/pubkey.asc
fingerprint: 1AD0 91ED B77A CC2B 87B1  4E51 012B 4BD2 8DC9 D62C



Sun, 09 May 2004 00:12:56 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. what's wrong with C#

2. What's wrong with apl\11?

3. Cincom Smalltalk - what's wrong here?

4. What's wrong with this?

5. What's wrong with this picture?

6. What's wrong with this code?

7. What's wrong with this code?

8. What's Wrong with this Line?

9. What's wrong with this???

10. What's wrong with this ???

11. What's wrong with this?

12. What's wrong?

 

 
Powered by phpBB® Forum Software