Re: Storing data and code in a Db with LISP-like interface
From: mAsterdam <mAsterdam_at_vrijdag.org>
Date: Fri, 28 Apr 2006 00:44:11 +0200
Message-ID: <445148f8$0$31644$e4fe514c_at_news.xs4all.nl>
>
>
> ------------------
> ?- person(P), likes(P, Thing), likes(P, Thing), fruit(Thing),
> vegetable(Thing).
>
> P = john
> Thing = tomato1 ;
>
> No
> ------------------
?- person(P), likes(P, Thing), fruit(Thing), vegetable(Thing).
but fortunately the result is the same. There is one combination of P and Thing satisfying the query. (You can read "No" as 'no more solutions'). Received on Fri Apr 28 2006 - 00:44:11 CEST
Date: Fri, 28 Apr 2006 00:44:11 +0200
Message-ID: <445148f8$0$31644$e4fe514c_at_news.xs4all.nl>
mAsterdam wrote:
> Neo wrote:
>>>> How do I express the following query in Prolog: >>>> Find a person who likes a fruit and a vegetable. >>>> (and (select person instance *) >>>> (select * like (and (select vegetable instance *) >>>> (select fruit instance *)))) >>> >>> >>> ?- person(P), likes(P, F), likes(P, V), fruit(F), vegetable(V). >> >> I actually expressed what I meant more clearly in the query then in >> english which was ambigious :( I meant find a person who likes >> something that is both a vegetable and a fruit.
>
>
> ------------------
> ?- person(P), likes(P, Thing), likes(P, Thing), fruit(Thing),
> vegetable(Thing).
>
> P = john
> Thing = tomato1 ;
>
> No
> ------------------
That should have been:
?- person(P), likes(P, Thing), fruit(Thing), vegetable(Thing).
P = john
Thing = tomato1 ;
No
but fortunately the result is the same. There is one combination of P and Thing satisfying the query. (You can read "No" as 'no more solutions'). Received on Fri Apr 28 2006 - 00:44:11 CEST