Re: how to make this fail driven loop succesfull ?

Carlo Capelli <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CABty9wwzUt8dSqw00HFC=ALDi0XaCt-rRcGxP-FvFmY7pSCWGw@mail.gmail.com>
2014-03-09 9:38 GMT+01:00 Roelof Wobben <[email protected]>:

>
>
> ----------------------------------------
> > Date: Sat, 8 Mar 2014 21:43:03 +0000
> > From: [email protected]
> > To: [email protected]
> > Subject: Re: [SWIPL] how to make this fail driven loop succesfull ?
> >
> > Roelof,
> >
> > You can make your failure-drive loop finish as 'true' like this:
> >
> > siblings(Father,Mother) :- is_father(X, Father), is_mother(X, Mother),
> write(X), nl, fail ; true.
> >
>
>
> I found a better way as stated in the tutorial :
>
>
> siblings(Father,Mother) :-
>
>    is_father(X, Father),
>
>    is_mother(X, Mother),
>
>    write(X),
>
>    nl,
>
>    fail.
>
>    siblings(_,_).
>
>
I would prefer to use builtin support

siblings(Father,Mother) :- forall(( is_father(X, Father), is_mother(X,
Mother) ), writeln(X)).


>
> But thanks for the help.
>
>
> Roelof
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
-------------- next part --------------
HTML attachment scrubbed and removed
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.