[m-rev.] For review 1/2: Beefed up the pqueue implementation.
Julien Fischer
jfischer at opturion.com
Wed Nov 27 16:08:22 AEDT 2013
On Tue, Nov 26, 2013 at 4:15 PM, Peter Wang <novalazy at gmail.com> wrote:
> On Sun, 24 Nov 2013 15:42:14 +1100, Paul Bone <paul at bone.id.au> wrote:
> > +
> > +:- pred pqueue.merge2(pqueue(K, V)::in, pqueue(K, V)::in, pqueue(K,
> V)::out)
> > + is det.
> > +
> > +pqueue.merge2(empty, B, B).
> > +pqueue.merge2(A at pqueue(_, _, _, _, _), empty, A).
> > +pqueue.merge2(pqueue(_, K, V, L, R), !.PQ at pqueue(_, _, _, _, _),
> !:PQ) :-
> > + pqueue.merge2(L, !PQ),
> > + pqueue.merge2(R, !PQ),
> > + pqueue.insert(K, V, !PQ).
>
> pqueue.merge2(A, B, C) :-
> (
> A = empty,
> C = B
> ;
> A = pqueue(_, _, _, _, _),
> B = empty,
> C = A
> ;
> A = pqueue(_, K, V, L, R),
> B = pqueue(_, _, _, _, _),
> merge2(L, B, C0),
> merge2(R, C0, C1),
> insert(K, V, C1, C)
> ).
I suggest s/merge2/merge_2/ or s/merge2/do_merge/. The library tends to use
names of the form <<name>>N (without an underscore) for non-auxiliary
predicates
that operate on N of something (or have N accumulators).
Cheers,
Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20131127/8d740945/attachment.html>
More information about the reviews
mailing list