USING: accessors arrays delegate delegate.protocols io.pathnames kernel locals namespaces prettyprint sequences ui.frp vectors ; IN: file-trees TUPLE: tree node children ; CONSULT: sequence-protocol tree children>> ; : ( start -- tree ) V{ } clone [ tree boa dup children>> ] [ ".." swap tree boa ] bi swap push ; DEFER: (tree-insert) : tree-insert ( path tree -- ) [ unclip ] [ children>> ] bi* (tree-insert) ; :: (tree-insert) ( path-rest path-head tree-children -- ) tree-children [ node>> path-head node>> = ] find nip [ path-rest swap tree-insert ] [ path-head tree-children push path-rest [ path-head tree-insert ] unless-empty ] if* ; : create-tree ( file-list -- tree ) [ path-components ] map t [ [ tree-insert ] curry each ] keep ; : ( tree-model -- table ) [ node>> 1array ] >>quot [ selected-value>> ] [ swap >>model ] bi ;