]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: fix map-reduce to have ..a on the stack for the first call.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 24 Oct 2017 01:01:15 +0000 (18:01 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 24 Oct 2017 01:01:15 +0000 (18:01 -0700)
core/sequences/sequences.factor

index f0d5648f81eb8a5d2b9999f6417aed1717ce2621..e6b56ad21f279703d648a6b9bf0bb4b950bd2901 100644 (file)
@@ -1001,12 +1001,10 @@ PRIVATE>
     [ rest-slice ] [ first-unsafe ] bi ; inline
 
 : map-reduce ( ..a seq map-quot: ( ..a elt -- ..b intermediate ) reduce-quot: ( ..b prev intermediate -- ..a next ) -- ..a result )
-    [ [ dup first ] dip [ call ] keep ] dip compose
-    swapd 1 each-from ; inline
+    [ [ [ first ] keep ] dip [ dip ] keep ] dip compose 1 each-from ; inline
 
 : 2map-reduce ( ..a seq1 seq2 map-quot: ( ..a elt1 elt2 -- ..b intermediate ) reduce-quot: ( ..b prev intermediate -- ..a next ) -- ..a result )
-    [ [ 2dup [ first ] bi@ ] dip [ call ] keep ] dip compose
-    [ -rot ] dip 1 2each-from ; inline
+    [ [ [ [ first ] bi@ ] 2keep ] dip [ 2dip ] keep ] dip compose 1 2each-from ; inline
 
 <PRIVATE