Safe Haskell | None |
---|

Some more utilities for Data.Tree.

- edges :: [Tree.Tree a] -> [(a, a)]
- paths :: [Tree.Tree a] -> [(Tree.Tree a, [Tree.Tree a])]
- flat_paths :: [Tree.Tree a] -> [(a, [a], [a])]
- find :: (a -> Bool) -> [Tree.Tree a] -> Maybe (Tree.Tree a)
- find_with_parents :: (a -> Bool) -> [Tree.Tree a] -> Maybe (Tree.Tree a, [Tree.Tree a])
- first_leaf :: Tree.Tree a -> a
- leaves :: Tree.Tree a -> [a]
- filter :: (a -> Bool) -> [Tree.Tree a] -> [Tree.Tree a]

# Documentation

paths :: [Tree.Tree a] -> [(Tree.Tree a, [Tree.Tree a])] Source #

Get every element along with its parents. The parents are closest first root last.

:: [Tree.Tree a] | |

-> [(a, [a], [a])] | (element, parents, children). Parents are closest first root last, children are in depth first order. |

Like `paths`

but the parents and children have been flattened.

find :: (a -> Bool) -> [Tree.Tree a] -> Maybe (Tree.Tree a) Source #

Given a predicate, return the first depthwise matching element and its children.

find_with_parents :: (a -> Bool) -> [Tree.Tree a] -> Maybe (Tree.Tree a, [Tree.Tree a]) Source #

Like `paths`

, but return only the element that matches the predicate.

first_leaf :: Tree.Tree a -> a Source #

Find the first leaf, always taking the leftmost branch.