Persistent heaps


This vocabulary implements persistent minheaps, aka priority queues. They are purely functional and support efficient O(log n) operations of pushing and popping, with O(1) time access to the minimum element. To create heaps, use the following words:
<persistent-heap> ( -- heap )

<singleton-heap> ( value prio -- heap )


To manipulate them:
pheap-peek ( heap -- value prio )

pheap-push ( value prio heap -- newheap )

pheap-pop ( heap -- newheap value prio )

pheap-pop* ( heap -- newheap )

pheap-empty? ( heap -- ? )

assoc>pheap ( assoc -- heap )

pheap>alist ( heap -- alist )

pheap>values ( heap -- seq )