Re: DCG

Feliks Kluzniak <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On Jul 10, 2013, at 22:09, Josef Frydl <[email protected]> wrote:

> Is there a way in DCG, to specify, that I want only the shortest solution, satisfying the Grammar rule?
> Thanks Josef Frydl

It is not quite clear what you mean by "the shortest solution".  Generating the shortest string?  Parsing the shortest string?  Coming up with the simplest parse tree?

Given some precise meaning, one can often achieve such effects by ordering the rules appropriately.

If this is not practical (or insufficiently declarative) _and_ if the number of "solutions" is finite, then one can generate all the solutions (with "findall" or its friends), and then find the "smallest" one.

If neither of these is appropriate, then I would say the answer is "no".

-- Feliks
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.