<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 26, 2013 at 4:15 PM, Peter Wang <span dir="ltr"><<a href="mailto:novalazy@gmail.com" target="_blank">novalazy@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Sun, 24 Nov 2013 15:42:14 +1100, Paul Bone <<a href="mailto:paul@bone.id.au">paul@bone.id.au</a>> wrote:<br>
> +<br>
> +:- pred pqueue.merge2(pqueue(K, V)::in, pqueue(K, V)::in, pqueue(K, V)::out)<br>
> + is det.<br>
> +<br>
> +pqueue.merge2(empty, B, B).<br>
> +pqueue.merge2(A@pqueue(_, _, _, _, _), empty, A).<br>
> +pqueue.merge2(pqueue(_, K, V, L, R), !.PQ@pqueue(_, _, _, _, _), !:PQ) :-<br>
> + pqueue.merge2(L, !PQ),<br>
> + pqueue.merge2(R, !PQ),<br>
> + pqueue.insert(K, V, !PQ).<br>
<br>
</div>pqueue.merge2(A, B, C) :-<br>
(<br>
A = empty,<br>
C = B<br>
;<br>
A = pqueue(_, _, _, _, _),<br>
B = empty,<br>
C = A<br>
;<br>
A = pqueue(_, K, V, L, R),<br>
B = pqueue(_, _, _, _, _),<br>
merge2(L, B, C0),<br>
merge2(R, C0, C1),<br>
insert(K, V, C1, C)<br>
).</blockquote><div><br></div><div>I suggest s/merge2/merge_2/ or s/merge2/do_merge/. The library tends to use</div><div>names of the form <<name>>N (without an underscore) for non-auxiliary predicates</div>
<div>that operate on N of something (or have N accumulators).</div><div><br></div><div>Cheers,</div><div>Julien.</div><div><br></div><div><br></div><div> </div></div></div></div>