Re: How to create a list of sharing variables?
- From: Wolfgang von Hansen <wolfgang0@xxxxxxxxx>
- Date: Fri, 15 Sep 2006 21:02:27 +0200
On Tue, 12 Sep 2006, bart demoen wrote:
1) only two problems in the book benefit from using assert; in most
contests, it was actually forbidden explicitly to use assert; the reason
is that using assert drives you away from logic (which Prolog is only
an approximation to anyway, but assert makes it worse)
I guess you are right with this. After successfully solving the task I saw
that my approach was quite different from the given solution. I hadn't
stored the crossword in an array but as a number of facts field(X,Y,_). I
also had the idea to transpose rows and columns but did it by replacing
the facts with transposed ones...
Now let me give a hint on how to implement the hint on page 9 of the book:
Thanks for your help. In fact, I got rid of the problem with the
non-sharing variables by storing all facts as objects in a list and using
member/2 to access them. BTW, I liked the predicate fill_in/2 from the
given solution. It is very elegant (even though not too quick).
This leads me to a different, but related question:
Given a general task, where the input consists of some objects (maybe of
more than one type) that shall be combined to create new objects (of a
different type). What would be the best way to represent the objects in a
Prolog program? Should I enter/assert them as facts or would it be better
to put them all into a single list?
Wolfgang
.
- Follow-Ups:
- Re: How to create a list of sharing variables?
- From: bart demoen
- Re: How to create a list of sharing variables?
- References:
- How to create a list of sharing variables?
- From: Wolfgang von Hansen
- Re: How to create a list of sharing variables?
- From: bart demoen
- How to create a list of sharing variables?
- Prev by Date: Re: SWI-Prolog : MySQL handle as global variable?
- Next by Date: Re: SWI not evaluating expression
- Previous by thread: Re: How to create a list of sharing variables?
- Next by thread: Re: How to create a list of sharing variables?
- Index(es):
Relevant Pages
|