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) ). -- JoachimReceived 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