Priority queue: Difference between revisions
m
→{{header|Logtalk}}
Line 4,364:
=={{header|Logtalk}}==
Logtalk comes with a [https://github.com/LogtalkDotOrg/logtalk3/tree/master/library/heaps heap implementation] out of the box. As such it by definition also has a priority queue. It can be used at the toplevel like this (with some formatting changes for clarity, and
<syntaxhighlight lang="logtalk">?- logtalk_load(heaps(loader)). % also `{heaps(loader)}.` on most back-ends
Line 4,389:
heap(<)::top(H4, K4, V4). % K4=2, V4='Tax return'</syntaxhighlight>
Since
<syntaxhighlight lang="logtalk">:- object(minheap,
Line 4,416:
:- end_object.</syntaxhighlight>
Given the presence of these two objects, all of the example code above could have
=={{header|Lua}}==
|