Skip to content

Operations on rose trees in Elm as defined in zwilias/elm-rosetree

License

Notifications You must be signed in to change notification settings

jxxcarlson/tree-extra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tree.Extra

Tree.Extra provides functions for working with rose trees as defined in [zwilias/elm-rosetree](attach gte targetNode subTree tree), e.g, removeSubTree, moveSubTree, and spanningTree. Here is an example:

    > import Tree  -- from zwilias/elm-rosetree
    > import Tree.Extra exposing(..)
    
    > s = Tree.singleton
    > t = Tree.tree 

    > a = t 1 [ t 2 [ s 3, t 4 [s 5, s 6]]]
    Tree 1 [Tree 2 [Tree 3 [],Tree 4 [Tree 5 [],Tree 6 []]]]

   > moveSubTree 4 1 a
    Just (Tree 1 [ Tree 2 [Tree 3 []]  
                 , Tree 4 [Tree 5 [],Tree 6 []]])

In certain cases, one assumes given a function that defines a partial order on nodes, or better said, labels of nodes:

bigger : a -> a -> Bool

For Tree Int, one can use

bigger = (>)

See the function attach for an example of this.

About

Operations on rose trees in Elm as defined in zwilias/elm-rosetree

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages