Re: [eclipse-clp-users] Request for code review

From: Joachim Schimpf <joachim.schimpf_at_...269...>
Date: Mon, 30 May 2011 08:55:00 +1000
Sergey Dymchenko wrote:
> Joachim, thanks for your review, it's really helpful!
> Also recently I read about shelves.  The tutorial says: "A typical
> application is counting of solutions...".
> So I think using shelf object to writeln "-1" in case there is no
> solution is a good idea. Am I right?

>From an efficiency point of view, yes.  Some examples are here

The reason I gave the findall-based solution was that it is the
textbook solution, and would work in all Prolog implementations.

Another possibility is

Note that, if you were not interested in multiple solutions,
you could have simply written

    ( solve(...) -> writeln(...solution...) ; writeln(-1) ).

-- Joachim
Received on Sun May 29 2011 - 22:55:14 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST