Subject: Re: [SWIPL] generating dynamic rules?

From: Bill Hollingsworth <[email-masked]>
Date: Wed, 07 Mar 2001 13:17:14 -0500

Hi,

Try this:

asserta(test:-(rule1,rule2)).

Bill Hollingsworth
http://www.billnet.org

At 05:41 PM 3/7/2001 +0100, Dietmar Harlos wrote:
>Hello,
>
>I have the following problem with SWI-Prolog. I have to generate a dynamic
>rule at runtime, but the variables don't match. Please see this short
>example:
>
>
>--- cut here --
>
>knot(1, fetch(Variable)).
>knot(2, write(Variable)).
>
>dynrule:-knot(1,Rule1), knot(2,Rule2), assert((testme:-Rule1,Rule2)),
>listing(testme), testme.
>
>fetch(A) :- A=4.
>
>--- cut there --
>
>
>The output at the prolog prompt is as follows:
>
>
>?- dynrule.
>
>testme :-
>         fetch(A),
>         write(B).
>_L114
>
>Yes
>?-
>
>
>Can anyone help me? Have I to process the two parts of the rule as strings?
>Is there any "string to rule" build-in predicate? You can answer me also in
>German.
>
>many greetings
>Dietmar
>
>
>
>
>
>
>
>
>----------------
>* To UNSUBSCRIBE, please use the HTML form at
>
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
>
>or send mail to [email-masked] using the Subject: "unsubscribe"
>(without the quotes) and *no* message body.
>
>** An ARCHIVE of this list is maintained at
>
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/