[m-users.] add rules at runtime

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Nov 7 03:46:15 AEDT 2018



On Tue, 6 Nov 2018 09:37:23 -0500, Jeffrey Brown <jeffbrown.the at gmail.com> wrote:
> What kind of data structure does Mercury itself use to represent rules?

That depends on what you mean by "rules". If you mean Prolog-style clauses,
the answer is that Mercury has nothing similar. (The Mercury compiler of course
does have ways to represent clauses internally, but these representations are not visible
outside the compiler.) On the other hand, if you mean sets of facts, the Mercury
standard library has a whole bunch of different data structures you can use.
Which ones are appropriate depends on the problem at hand. The list of modules is
available at http://mercurylang.org/information/doc-release/mercury_library/index.html.

> 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.

For binary relationships, the Mercury standard library's bimap module
may be what you need. For relationships among three or more entities,
you will have to roll your own.

Zoltan.


More information about the users mailing list