Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Better, but not good
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
>
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Paul Summer
10-02-04 01:56 AM


Re: Better, but not good
> rule(L1,L2) :- ( addfacts(L2) :- alltrue(L1) ).

Try:
rule(L1, L2) :- (alltrue(L1) -> addfacts(L2) ; true).

Dave





Report this thread to moderator Post Follow-up to this message
Old Post
David Vago
10-02-04 01:56 AM


Re: Better, but not good
Thank 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



Report this thread to moderator Post Follow-up to this message
Old Post
Paul Summer
10-02-04 01:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:50 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.