Code Comments
Programming Forum and web based access to our favorite programming groups.Now, I changed my program as followed:
%*************************************
my_fact1.
my_fact2.
alltrue([]).
alltrue([Head|Tail]) :- call(Head), alltrue(Tail).
addfacts([]).
addfacts([Head|Tail]) :- assert(Head), addfacts(Tail).
rule(L1,L2) :- ( addfacts(L2) :- alltrue(L1) ).
rule([my_fact1, my_fact2], [new_fact3]).
%*************************************
Now I get no more compiler-errors, but when I ask for "new_fact3" then it is
still unknown ("undefined_predicate")... Why?
Paul
"Paul Summer" <psummer1@yahoo.com> schrieb im Newsbeitrag
news:2s5rijF1h979eU1@uni-berlin.de...
> Hello again,
>
> I have another question to lists...
>
> Here my code:
>
> %*************************************
> my_fact1.
> my_fact2.
>
> alltrue([]).
> alltrue([Head|Tail]) :- call(Head), alltrue(Tail).
>
> rule(L1, L2) :- L2 :- alltrue(L1). % this part don't work
>
>
> rule([my_fact1, my_fact2], [new_fact3]).
> %*************************************
>
> I want to set up rules in the following way:
>
> My rules are represented by rule(L1,L2) where L1 is a list of facts which
> must be true in order to draw the conlusions in the list L2.
> With other words: I check with "alltrue", whether L1 is completely true
> and then I want to set the members of L2 also true. To do this, I want to
> use the "rule()" in a general way. But there is a error in "rule()".
>
> What is wrong?
>
> Greetz,
>
> Paul
>
>
>
Post Follow-up to this message> rule(L1,L2) :- ( addfacts(L2) :- alltrue(L1) ). Try: rule(L1, L2) :- (alltrue(L1) -> addfacts(L2) ; true). Dave
Post Follow-up to this messageThank you David, now it works, when I type in "rule([my_fact1, my_fact2], [new_fact3])." in the command line (then I can ask for new_fact3). But when I write the rule directly in my source-file (as I did in my example), then I can't ask for "new_fact3". How can I write my rule "rule([my_fact1, my_fact2], [new_fact3])." directly into my source-file, so that I can ask for new_fact3 and I get a "yes"? Thanks, Paul
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.