Re: how to make this fail driven loop succesfull ?
"Richard A. O'Keefe" <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 9/03/2014, at 9:38 PM, Roelof Wobben wrote: > > > ---------------------------------------- >> 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(_,_). It isn't a better way. It's the *same* way, if you consider the logic of it.