]> gitweb.factorcode.org Git - factor.git/commitdiff
sorting.insertion: skip the zero'th element.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 28 Apr 2014 00:13:26 +0000 (17:13 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 28 Apr 2014 00:13:26 +0000 (17:13 -0700)
basis/sorting/insertion/insertion.factor

index a1752b6742648b2900ff62518eeda3090845b14d..2145e46927997075cc92c50cbff49e1cc1e06a20 100644 (file)
@@ -2,6 +2,7 @@ USING: kernel locals math sequences sequences.private ;
 IN: sorting.insertion
 
 <PRIVATE
+
 :: insert ( ... seq quot: ( ... elt -- ... elt' ) n -- ... )
     n zero? [
         n n 1 - [ seq nth-unsafe quot call ] bi@ >= [
@@ -9,8 +10,9 @@ IN: sorting.insertion
             seq quot n 1 - insert
         ] unless
     ] unless ; inline recursive
+
 PRIVATE>
 
 : insertion-sort ( ... seq quot: ( ... elt -- ... elt' ) -- ... )
     ! quot is a transformation on elements
-    over length [ insert ] with with each-integer ; inline
+    over length [ insert ] with with 1 -rot (each-integer) ; inline