[mercury-users] Emacs mode; a_solution?
Ralph Becket
rafe at cs.mu.OZ.AU
Thu Jan 3 12:38:58 AEDT 2002
Douglas Michael Auclair, Thursday, 3 January 2002:
> Hi, I'm starting to program in Mercury to address some issues I have
> parsing a data description language. I have a few questions:
>
> * Is there an emacs mode somewhere? I'm not looking for gud.el (I
> think), I'm looking for a fontifier, indenter, and (aiming high)
> interpreter for Mercury code in Emacs.
'Fraid we're all Vim users in this office. Join us. Come to the light.
Alternatively, there's almost certainly someone out there on this list
with an Emacs mode for Mercury.
> * How does one get only 1 solution of n solutions? For example, how
> would one implement next_permutation([1, 2, 3, 4], L)? The
> documentation makes it sound trivial, but I seem to be missing some
> fundamentals to get there.
Assuming the definition
perm([], []).
perm([X | Xs], Zs) :-
perm(Xs, Ys),
insert_somewhere(X, Ys, Zs).
then I can supply a mode declaration
:- mode perm(in, out) is multi.
which would allow me to call it anywhere (probably leaving a choice
point around) or I could declare
:- mode perm(in, out) is cc_multi.
which would guarantee that I would only get one solution for any given
argument (`cc' stands for `committed choice').
You'd then have to promote the cc_ determinism declarations up to all
predicates that depend on perm/2.
> * Is there a method to solving a system of equations (m variables over
> n equations, m <= n)? Not talking CLP, as there is only one solution
> over the systems I'm working ... I get unbound errors when I try:
>
> system_of_eqns(A, B) :- 2 * A + B = 5, A - B = 7.
The Mercury modes for integer addition and subtraction work where any
two of the three arguments are inputs (this isn't true for
multiplication or floats). However, there's no way of reordering your
goals to satisfy the two-input requirement, which is why Mercury is
reporting an error.
You could implement Gaussian elimination, I suppose.
> * Writing of CLP ... is constraints.m available for hacking on (I saw
> mention of it in an archive)? I saw the CLP(R) implementation in the
> extras package with the associated warnings. I was wondering if there
> was an open-source, freely-usable implementation to work on and to
> use. HAL seems like it's too far from Mercury for what I need.
I believe gnuprolog includes CLP(R).
- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list