Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, how can I define a predicate alltrue(L) that checks whether all facts in the list L are true (please with code)? Greetz, Paul
Post Follow-up to this messageWell, it is fairly simple, just think about it for a short time. Surely, when L is an empty list, alltrue(L) must succeed. If L contains at least one element, than the first element must be a true fact, and alltrue/1 must be true for the tail of the list. After you had thought about it, you can simply write the code just be following the logical reasoning. alltrue([]). alltrue([Head|Tail]) :- call(Head), alltrue(Tail). Dave "Paul Summer" <psummer1@yahoo.com> wrote in message news:2s5e92F1f6n8rU1@uni-berlin.de... > Hi, > > how can I define a predicate alltrue(L) that checks whether all facts in > the list L are true (please with code)? > > Greetz, > > Paul >
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.