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

From: Joachim Schimpf <joachim.schimpf_at_monash.edu>
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
http://eclipseclp.org/doc/bips/kernel/storage/shelf_create-2.html

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
http://eclipseclp.org/doc/bips/kernel/control/X-G-2.html

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 : Thu Feb 02 2012 - 02:31:58 CET