]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/vocabs/hierarchy/hierarchy.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / vocabs / hierarchy / hierarchy.factor
index fe791df64d67349ea988b52d76269e6533fa3d68..07c2097e35b1b868c0ba5f5aac18622be4f0c836 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: accessors arrays assocs combinators.short-circuit fry\r
-io.directories io.files io.files.info io.pathnames kernel make\r
+io.directories io.files io.files.types io.pathnames kernel make\r
 memoize namespaces sequences sorting splitting vocabs sets\r
 vocabs.loader vocabs.metadata vocabs.errors ;\r
 RENAME: child-vocabs vocabs => vocabs:child-vocabs\r
@@ -15,12 +15,16 @@ M: vocab-prefix vocab-name name>> ;
 \r
 <PRIVATE\r
 \r
-: vocab-subdirs ( dir -- dirs )\r
+: visible-dirs ( seq -- seq' )\r
     [\r
-        [\r
-            { [ link-info directory? ] [ "." head? not ] } 1&&\r
-        ] filter\r
-    ] with-directory-files natural-sort ;\r
+        {\r
+            [ type>> +directory+ = ]\r
+            [ name>> "." head? not ]\r
+        } 1&&\r
+    ] filter ;\r
+\r
+: vocab-subdirs ( dir -- dirs )\r
+    directory-entries visible-dirs [ name>> ] map! natural-sort ;\r
 \r
 : vocab-dir? ( root name -- ? )\r
     over\r
@@ -37,7 +41,7 @@ ERROR: vocab-root-required root ;
     [ ensure-vocab-root ] [ check-vocab-name ] bi* ;\r
 \r
 : (child-vocabs) ( root prefix -- vocabs )\r
-    ensure-vocab-root/prefix\r
+    check-vocab-name\r
     [ vocab-dir append-path dup exists? [ vocab-subdirs ] [ drop { } ] if ]\r
     [ nip [ "." append '[ _ prepend ] map! ] unless-empty ]\r
     [ drop '[ _ over vocab-dir? [ >vocab-link ] [ <vocab-prefix> ] if ] map! ]\r
@@ -48,9 +52,10 @@ ERROR: vocab-root-required root ;
     [ ((child-vocabs-recursive)) ] with each ;\r
 \r
 : (child-vocabs-recursive) ( root prefix -- seq )\r
+    [ ensure-vocab-root ] dip\r
     [ ((child-vocabs-recursive)) ] { } make ;\r
 \r
-: no-rooted ( seq -- seq' ) [ find-vocab-root not ] filter ;\r
+: no-rooted ( seq -- seq' ) [ find-vocab-root ] reject ;\r
 \r
 : one-level-only? ( name prefix -- ? )\r
     ?head [ "." split1 nip not ] [ drop f ] if ;\r
@@ -65,17 +70,17 @@ ERROR: vocab-root-required root ;
 \r
 PRIVATE>\r
 \r
-: no-prefixes ( seq -- seq' ) [ vocab-prefix? not ] filter ;\r
+: no-prefixes ( seq -- seq' ) [ vocab-prefix? ] reject ;\r
 \r
 : convert-prefixes ( seq -- seq' )\r
-    [ dup vocab-prefix? [ name>> vocab-link boa ] when ] map ;\r
+    [ dup vocab-prefix? [ name>> <vocab-link> ] when ] map ;\r
 \r
 : remove-redundant-prefixes ( seq -- seq' )\r
     #! Hack.\r
     [ vocab-prefix? ] partition\r
     [\r
         [ vocab-name ] map fast-set\r
-        '[ name>> _ in? not ] filter\r
+        '[ name>> _ in? ] reject\r
         convert-prefixes\r
     ] keep\r
     append ;\r
@@ -131,7 +136,7 @@ PRIVATE>
 \r
 : (load-from-root) ( root prefix -- failures )\r
     vocabs-in-root/prefix\r
-    [ don't-load? not ] filter no-prefixes\r
+    [ don't-load? ] reject no-prefixes\r
     require-all ;\r
 \r
 : load-from-root ( root prefix -- )\r