Safe Haskell | Safe-Inferred |
---|

Some more utilities for Data.Tree.

## Synopsis

- edges :: [Tree.Tree a] -> [(a, a)]
- paths :: [Tree.Tree a] -> [(Tree.Tree a, [Tree.Tree a])]
- flatPaths :: [Tree.Tree a] -> [(a, [a], [a])]
- find :: (a -> Bool) -> [Tree.Tree a] -> Maybe (Tree.Tree a)
- findAll :: (a -> Bool) -> [Tree.Tree a] -> [Tree.Tree a]
- findWithParents :: (a -> Bool) -> [Tree.Tree a] -> Maybe (Tree.Tree a, [Tree.Tree a])
- leaves :: Tree.Tree a -> [a]
- filter :: (a -> Bool) -> Tree.Tree a -> Maybe (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.

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

Return the unmodified subtrees that match the predicate. This is like
`find`

, except that it returns all matching subtrees instead of the first
one.