]> gitweb.factorcode.org Git - factor.git/commitdiff
sorting.extras: better tests and fix zip order.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 2 Apr 2013 03:31:34 +0000 (20:31 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 2 Apr 2013 03:31:34 +0000 (20:31 -0700)
extra/sorting/extras/extras-tests.factor
extra/sorting/extras/extras.factor

index 49916e6248a867e596377f7e679e70e72b85b984..4df1ac9e45a07e2438d6956260e45b4b12597ddd 100644 (file)
@@ -6,4 +6,7 @@ IN: sorting.extras
     { "hello" "goodbye" "yo" } [ [ length ] bi@ <=> ] argsort
 ] unit-test
 
-{ 1 { 2 3 4 5 } } [ 1 { 1 2 3 4 } [ dupd + ] map-sort ] unit-test
+{ { "blue" "green" "purple" } } [
+    { "green" "blue" "purple" } [ length ] map-sort
+] unit-test
+{ 1 { 1 2 3 4 } } [ 1 { 4 2 1 3 } [ dupd + ] map-sort ] unit-test
index 72d2e1574fca44b36c811395bfbcdde83c268101..a686b8d9fb74f2febcee0fc464c65e0b3ac786d5 100644 (file)
@@ -7,5 +7,5 @@ IN: sorting.extras
     sort [ second-unsafe ] map! ; inline
 
 : map-sort ( ... seq quot: ( ... elt -- ... key ) -- ... sortedseq )
-    [ map ] curry keep zip [ second-unsafe ] sort-with
-    [ first-unsafe ] map ; inline
+    [ map ] curry keep zip [ first-unsafe ] sort-with
+    [ second-unsafe ] map ; inline