Home > Archive > Prolog > October 2004 > Invoke Rules in Source-File
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Invoke Rules in Source-File
|
|
| Paul Summer 2004-10-02, 8:58 am |
| Hello,
how can I directly invoke Rules in my Source-File. For example I have the
following code:
%***************************************
***************
my_Fact1.
my_Fact2.
alltrue([]).
alltrue([Head|Tail]) :- call(Head), alltrue(Tail).
addfacts([]).
addfacts([Head|Tail]) :- assert(Head), addfacts(Tail).
rule(L1, L2) :- (alltrue(L1) -> addfacts(L2) ; true).
rule([my_Fact1, my_Fact2], [my_Fact3]). %here is the problem!!!
%***************************************
***************
My problem now is, that my rule doesn't work, i.e. when I ask "my_Fact1" I
get "yes", but when I ask "my_Fact3" I get "no".
If I write "rule([my_Fact1, my_Fact2], [my_Fact3])." directly in the
command-line then I can ask for "my_fact3" (yes).
So, what can I do to invoke the rule in the source-code like I have
described here?
Thanks,
Paul
| |
| Markus Triska 2004-10-02, 3:56 pm |
| Paul Summer wrote:
>
> So, what can I do to invoke the rule in the source-code like I have
> described here?
>
This depends on your implementation. Did you try
:- rule([my_Fact1, my_Fact2], [my_Fact3]).
already?
Best regards,
Markus.
|
|
|
|
|