[m-users.] add rules at runtime

Jeffrey Brown jeffbrown.the at gmail.com
Wed Nov 7 01:37:23 AEDT 2018


Thanks! I had no idea I should read that.

What kind of data structure does Mercury itself use to represent rules? I'd
like to be able to search for information in any direction -- i.e., using
the terminology of maps, any member of any relationship could be treated as
a key or a value.

On Tue, Nov 6, 2018 at 12:41 AM Julien Fischer <jfischer at opturion.com>
wrote:

>
> Hi Jeff,
>
> On Mon, 5 Nov 2018, Jeffrey Brown wrote:
>
> > I want to write a program in Mercury that lets a user add (simple
> > nonrecursive) rules at runtime, like "Bob knows Mary" or "eukaryotes
> > use oxygen". Is it possible?
>
> If you mean, is it possible to do it as in Prolog, using assert/1 and
> retract/1 to modify the clause database, then no.  Mercury does not
> support that.
>
> In Mercury you would need to define your own data structures to hold the
> rules added a runtime (or use some of the ones in the standard library.)
>
> The section "Assert and retract" in the Prolog to Mercury transition
> guide has further details.
>
> Julien.
>


-- 
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/>   |   Facebook
<https://www.facebook.com/mejeff.younotjeff>   |   LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here)   |   Github <https://github.com/jeffreybenjaminbrown>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20181106/250ef985/attachment.html>


More information about the users mailing list