Re: Why does this not work ?
Feliks Kluzniak <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
Works for me, and I pasted it directly from your message (see below).
Did you perhaps put
inventaris(X,Y),item(X,pan,0).
together with the facts in the file?
If you don’t do the query interactively, you’d better make it a query:
?- inventaris(X,Y),item(X,pan,0).
but that will only give you a yes (plus a warning about Y).
So it’s better to do
?- inventaris(X,Y), item(X,pan,0), write( X ).
or
:- inventaris(X,Y), item(X,pan,0), write( X ).
if you don’t want the „yes”
or
:- inventaris(X,_), item(X,pan,0), write( X ).
if you don’t want the warning.
Hope this helps.
— Feliks
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.6.2)
Copyright (c) 1990-2013 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- consult(user).
customer(wobben, musselkanaal, aaa).
|:
|: customer(ankone, hengelo, bbb).
|:
|: customer("de jong", haaksbergen, ccc).
|:
|:
|: item(1, pan, 0).
|:
|: item(2, beker, 1).
|:
|:
|: inventaris( 1, 12).
|:
|: inventaris( 2, 10).
|: % user://1 compiled 0.00 sec, 8 clauses
true.
?- inventaris(X,Y),item(X,pan,0).
X = 1,
Y = 12 .
?-
On Mar 7, 2014, at 20:05, Roelof Wobben <[email protected]> wrote:
> Hello,
>
>
> I have this problem.
>
>
> Write a query against the item and inventory records that returns the inventory level for an item when you only know the item name.
>
>
> I have this facts:
>
>
> customer(wobben, musselkanaal, aaa).
>
> customer(ankone, hengelo, bbb).
>
> customer("de jong", haaksbergen, ccc).
>
>
> item(1, pan, 0).
>
> item(2, beker, 1).
>
>
> inventaris( 1, 12).
>
> inventaris( 2, 10).
>
>
>
> So I tried this:
>
>
> inventaris(X,Y),item(X,pan,0).
>
>
> But it gives me a no where I expected it to be 12.
>
>
> Roelof
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog