]> gitweb.factorcode.org Git - factor.git/commitdiff
heaps: change slurp-heap to slurp keys and values.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 1 Dec 2014 23:14:25 +0000 (15:14 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 1 Dec 2014 23:14:25 +0000 (15:14 -0800)
basis/heaps/heaps-docs.factor
basis/heaps/heaps.factor
extra/sorting/heap/heap.factor

index 3888951f6bd36045ea8153573ea13d73e263beae..c9d5946bbfac4e9f7a99c97a7ae3f76238ba5c4b 100644 (file)
@@ -96,6 +96,5 @@ HELP: heap-delete
 { $side-effects "heap" } ;
 
 HELP: slurp-heap
-{ $values
-     { "heap" heap } { "quot" quotation } }
-{ $description "Removes values from a heap and processes them with the quotation until the heap is empty." } ;
+{ $values { "heap" heap } { "quot" { $quotation ( value key -- ) } } }
+{ $description "Removes entries from a heap and processes them with the quotation until the heap is empty." } ;
index 509ff9279ee64ddd1131e96bd16fcd730f0048a9..fb299a12c991400ad88a49084f663f32d452900f 100644 (file)
@@ -189,9 +189,9 @@ ERROR: not-a-heap object ;
 : check-heap ( heap -- heap )
     dup heap? [ not-a-heap ] unless ; inline
 
-: slurp-heap ( heap quot: ( elt -- ) -- )
+: slurp-heap ( heap quot: ( value key -- ) -- )
     [ check-heap ] dip over heap-empty? [ 2drop ] [
-        [ [ heap-pop drop ] dip call ] [ slurp-heap ] 2bi
+        [ [ heap-pop ] dip call ] [ slurp-heap ] 2bi
     ] if ; inline recursive
 
 : >min-heap ( assoc -- min-heap )
index eb5a11cc8c7afb0f703dc9409e0a1bac3bf783fa..b036030d438d779a13c0f29287ea9a8b328f21d8 100644 (file)
@@ -8,7 +8,7 @@ IN: sorting.heap
 <PRIVATE
 
 : (heapsort) ( alist accum -- sorted-seq )
-    [ >min-heap ] [ [ [ push ] curry slurp-heap ] keep ] bi* ; inline
+    [ >min-heap ] [ [ [ nip push ] curry slurp-heap ] keep ] bi* ; inline
 
 PRIVATE>