semantic-db: got rid of uniq in favour of prune

db4
Alex Chapman 2008-03-13 15:22:16 +11:00
parent 2084234719
commit 4a4aeb821e
1 changed files with 3 additions and 6 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Alex Chapman ! Copyright (C) 2008 Alex Chapman
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors db.tuples kernel new-slots semantic-db USING: accessors db.tuples hashtables kernel new-slots
semantic-db.relations sorting sequences sequences.deep ; semantic-db semantic-db.relations sorting sequences ;
IN: semantic-db.hierarchy IN: semantic-db.hierarchy
TUPLE: tree id children ; TUPLE: tree id children ;
@ -34,9 +34,6 @@ C: <tree> tree
: get-node-hierarchy ( node-id -- tree ) : get-node-hierarchy ( node-id -- tree )
dup children [ get-node-hierarchy ] map <tree> ; dup children [ get-node-hierarchy ] map <tree> ;
: uniq ( sorted-seq -- seq )
f swap [ tuck = not ] subset nip ;
: (get-root-nodes) ( node-id -- root-nodes/node-id ) : (get-root-nodes) ( node-id -- root-nodes/node-id )
dup parents dup empty? [ dup parents dup empty? [
drop drop
@ -45,4 +42,4 @@ C: <tree> tree
] if ; ] if ;
: get-root-nodes ( node-id -- root-nodes ) : get-root-nodes ( node-id -- root-nodes )
(get-root-nodes) flatten natural-sort uniq ; (get-root-nodes) flatten prune ;