heaps: Add >min-heap, >max-heap.
parent
c74939e43b
commit
bfe0ace611
|
@ -194,3 +194,9 @@ ERROR: not-a-heap obj ;
|
||||||
[ check-heap ] dip over heap-empty? [ 2drop ] [
|
[ check-heap ] dip over heap-empty? [ 2drop ] [
|
||||||
[ [ heap-pop drop ] dip call ] [ slurp-heap ] 2bi
|
[ [ heap-pop drop ] dip call ] [ slurp-heap ] 2bi
|
||||||
] if ; inline recursive
|
] if ; inline recursive
|
||||||
|
|
||||||
|
: >min-heap ( assoc -- min-heap )
|
||||||
|
<min-heap> [ heap-push-all ] keep ;
|
||||||
|
|
||||||
|
: >max-heap ( assoc -- min-heap )
|
||||||
|
<max-heap> [ heap-push-all ] keep ;
|
||||||
|
|
Loading…
Reference in New Issue