Article View: comp.lang.prolog
Article #213Re: Help needed with DCG.
From: Michael A. Covington
Date: Thu, 16 Apr 1992 15:49
Date: Thu, 16 Apr 1992 15:49
25 lines
1448 bytes
1448 bytes
> retrieve country where Population > 10000 You don't want 'Population' to be a Prolog variable here. If it were, you would not be able to distinguish it from 'Area' or 'Government' or 'TotalNumberOfUnicornsInTheKingsPalace'. Remember, variables only have names while being input; as soon as Prolog determines which variables are which, it forgets the names. What you want to do is tokenize this as [retrieve, country, where, population, >, 10000] and then parse it in such a way that a variable for the population gets generated, giving a query something like this: ?- country(X), population(X,Y), Y > 10000, display(X). See Chapter 4 (maybe 3 after reorganization) of my book that will be published a year or two hence... -- ========================================================================== Michael A. Covington, Ph.D. | mcovingt@uga.cc.uga.edu | ham radio N4TMI Artificial Intelligence Programs | U of Georgia | Athens, GA 30602 U.S.A. ==========================================================================
Technical Details
Message-ID:
<1992Apr16.154937.22618@athena.cs.uga.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!sol.ctr.columbia.edu!emory!athena.cs.uga.edu!mcovingtReferences:
<4849@umriscc.isc.umr.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sol.ctr.columbia.edu!emory!athena.cs.uga.edu!mcovingt From: mcovingt@athena.cs.uga.edu (Michael A. Covington) Newsgroups: comp.lang.prolog Subject: Re: Help needed with DCG. Message-ID: <1992Apr16.154937.22618@athena.cs.uga.edu> Date: 16 Apr 92 15:49:37 GMT References: <4849@umriscc.isc.umr.edu> Organization: University of Georgia, Athens Lines: 25