]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/sorting/human/human.factor
factor: trim using lists
[factor.git] / basis / sorting / human / human.factor
index ceef6f2a153dd580f139592a222169094dc0e22d..9e311ca03ac2500705453b84b93f829f42605e77 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2008, 2010 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors fry kernel make math math.order math.parser
-sequences sorting.functor strings unicode.case
-unicode.categories unicode.collation ;
+USING: accessors kernel make math math.order math.parser
+sequences sorting.functor strings unicode ;
 IN: sorting.human
 
 : cut-find ( sequence pred -- before after )
@@ -25,17 +24,17 @@ IN: sorting.human
     [ digit? ] [ string>number ] find-sequences ;
 
 ! For comparing integers or sequences
-TUPLE: hybrid obj ;
+TUPLE: alphanum obj ;
 
-: <hybrid> ( obj -- hybrid )
-    hybrid new
+: <alphanum> ( obj -- alphanum )
+    alphanum new
         swap >>obj ; inline
 
-: <hybrid-insensitive> ( obj -- hybrid )
-    hybrid new
-        swap dup string? [ w/collation-key ] when >>obj ; inline
+: <alphanum-insensitive> ( obj -- alphanum )
+    alphanum new
+        swap dup string? [ collation-key/nfd drop ] when >>obj ; inline
 
-M: hybrid <=>
+M: alphanum <=>
     [ obj>> ] bi@
     2dup [ integer? ] bi@ xor [
         drop integer? +lt+ +gt+ ?
@@ -43,5 +42,5 @@ M: hybrid <=>
         <=>
     ] if ;
 
-<< "human" [ find-numbers [ <hybrid> ] map ] define-sorting >>
-<< "humani" [ find-numbers [ <hybrid-insensitive> ] map ] define-sorting >>
+<< "human" [ find-numbers [ <alphanum> ] map ] define-sorting >>
+<< "humani" [ find-numbers [ <alphanum-insensitive> ] map ] define-sorting >>