sorting.extras: better tests and fix zip order.

db4
John Benediktsson 2013-04-01 20:31:34 -07:00
parent 9d6f2ad353
commit fd7ec79b20
2 changed files with 6 additions and 3 deletions

View 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

View 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