For Programmers: Free Programming Magazines  


Home > Archive > Prolog > April 2005 > Re: newcomer question. Just testing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: newcomer question. Just testing
George Sp

2005-04-13, 3:59 pm

Just a test. My messages does not seem to appear in this group. Just testing.
Sorry for the inconvenience.

"Anders Lindén" <xxxx@xxx.xx> wrote in message
news:4259a20c$1@griseus.its.uu.se...
> Hello!
>
> I have this scenario:
> There is a lot of beer sorts.
> There are also some pubs where they sell beer.
> beerkind is a predicate that tells that a certain pub has a certain beer.
> What I wanted to do was to write a predicate that can tell if there is a beer
> that is only sold in one pub.
> Its used by writing onepub(X)., and seems to work.
> It uses a predicate that can tell if a beer is sold in _many_ pubs, which is
> used by manypubs(X)..
> However, it has the weakness of listing a certain beer many times!
> How is that solved?
>
> source follows:
>
>
> beer(guinness).
> beer(fiddlers_armbow).
> beer(pripps_bla).
> beer(pripps_yellow).
> beer(fulblask).
>
> pub(mcgills).
> pub(sheers).
> pub(pelles).
> pub(nisses).
> beerkind(mcgills, guinness). % mcgills has guinness
> beerkind(mcgills, fiddlers_armbow).
> beerkind(sheers, pripps_bla).
> beerkind(sheers, guinness).
> beerkind(nisses, pripps_yellow).
> beerkind(pelles, pripps_yellow).
> beerkind(pelles, guinness).
>
> manypubs(X):- beerkind(A,X),beerkind(B,X),different(A,
B).
> nopubs(X):- beer(X),not(beerkind(_,X)).
> onepub(X):- beer(X),not(manypubs(X)),not(nopubs(X)).
> not(X):- X,!,fail;true.
> different(X,Y):- not(X=Y).
>
>


Anders Lindén

2005-04-14, 3:58 pm

its ok, your message came in 3 copies, maybe you should get another news reader? :)

I have not tested what you have written yet, I just read it, but it certainly seems interesting!

/Anders


"George Sp" <nobots@noagents.com> wrote in message news:d3jikc$s2g$1@titan.btinternet.com...
> Just a test. My messages does not seem to appear in this group. Just testing.
> Sorry for the inconvenience.
>
> "Anders Lindén" <xxxx@xxx.xx> wrote in message
> news:4259a20c$1@griseus.its.uu.se...
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com