Code Comments
Programming Forum and web based access to our favorite programming groups.Just a test. My messages does not seem to appear in this group. Just testin g. 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 b eer > 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). > >
Post Follow-up to this messageits ok, your message came in 3 copies, maybe you should get another news rea der? :) I have not tested what you have written yet, I just read it, but it certainl y 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 test ing. > Sorry for the inconvenience. > > "Anders Lindén" <xxxx@xxx.xx> wrote in message > news:4259a20c$1@griseus.its.uu.se... >
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.