vocabs: adding 'parent-vocab?' and 'parent-vocabs'.

db4
John Benediktsson 2011-09-25 18:32:03 -07:00
parent 82e34082ec
commit 46df742317
2 changed files with 14 additions and 0 deletions

View File

@ -3,3 +3,11 @@ USING: vocabs tools.test ;
IN: vocabs.tests
[ f ] [ "kernel" vocab-main ] unit-test
[ t ] [ "" "" child-vocab? ] unit-test
[ t ] [ "" "io.files" child-vocab? ] unit-test
[ t ] [ "io" "io.files" child-vocab? ] unit-test
[ f ] [ "io.files" "io" child-vocab? ] unit-test
[ t ] [ "io.files" "io" parent-vocab? ] unit-test
[ f ] [ "io" "io.files" parent-vocab? ] unit-test

View File

@ -111,6 +111,12 @@ ERROR: no-vocab name ;
: child-vocabs ( vocab -- seq )
vocab-name vocabs [ child-vocab? ] with filter ;
: parent-vocab? ( suffix name -- ? )
swap child-vocab? ;
: parent-vocabs ( vocab -- seq )
vocab-name vocabs [ parent-vocab? ] with filter ;
GENERIC: >vocab-link ( name -- vocab )
M: vocab-spec >vocab-link ;