Re: How to expand a search
- From: bart demoen <bmd@xxxxxxxxxxxxxx>
- Date: Sun, 15 Apr 2007 12:22:12 +0200
On Sat, 14 Apr 2007 17:51:55 -0700, RichardIII wrote:
Hi All,
I'm a Prolog nubie relying on a couple of on-line tutorial and the
documentation from SWI-Prolog, which I'm running on WinXP-Pro/SP2.
I found a simple example on the web that listed cuisine the "sam"
likes, which I expanded with what "joe" likes. The "facts" are shown
below, which are "consulted".
The queries:
12 ?- setof(Z, likes(sam, Z), Result).
13 ?- setof(Z, likes(joe, Z), Result).
14 ?- setof(Z, likes(Guy, Z), Result).
produce:
Result = [chips, pizza, spaghetti]
Result = [hero]
Guy = sam,
Result = [chips, pizza, spaghetti]
How can I embed #14 with a query that gets an array of all the Guys
and feeds them to #14 so that every Guy will be named followed by his
cuisines? Only sam gets returned in #14, no doubt because he's the
first Guy listed in the facts.
Maybe this what you want ?
?- setof(likesall(Guy,LikesAll), setof(Liked,likes(Guy,Liked),LikesAll),L).
Now L contains perhaps what you needed.
BTW, setof is a bit tricky, maybe you should stay away from it for a while.
Cheers
Bart Demoen
.
- Follow-Ups:
- Re: How to expand a search
- From: RichardIII
- Re: How to expand a search
- References:
- How to expand a search
- From: RichardIII
- How to expand a search
- Prev by Date: Re: Prolog beginner
- Next by Date: Re: Prolog beginner
- Previous by thread: Re: How to expand a search
- Next by thread: Re: How to expand a search
- Index(es):
Relevant Pages
|
|