Re: Can anyone explain this

Alan Baljeu <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
This is called a failure-driven loop. It works like this:
1) ask location/2 to find an X that matches location(X, kitchen). (I believe these would represent items in the kitchen.)
2) print that X
3) fail: go back to find alternate solution. location may come up with a second result. If it does, proceed forward again.
4) eventually there are no more solutions and the entire thing "fails". Presumably  the caller is expecting this and then proceeds onto something else.

This example is ordinary standard Prolog, but be aware that Amzi! is a different product than SWI, and you will encounter things there which don't fit this list. Does Amzi have its own forum?  

Alan Baljeu

On 2014-03-07, at 11:36 AM, roelof <[email protected]> wrote:

> Hello, 
> 
> Im following the Adventure in Prolog tutorial from Amzi.
> 
> then I see this : location(X, kitchen), write(X) ,nl, fail.
> 
> Why not just using : location(X, kitchen) 
> I can understand why write(X) is mentioned. that's  to write the item on
> screen.
> But why stop with fail ?
> 
> Roelof
> 
> 
> 
> 
> --
> View this message in context: http://swi-prolog.996271.n3.nabble.com/Can-anyone-explain-this-tp14432.html
> Sent from the SWI Prolog mailing list archive at Nabble.com.
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
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.