Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Util.Trees

Description

Some more utilities for Data.Tree.

Synopsis

Documentation

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

The edges of a forest, as (parent, child).

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.

flatPaths Source #

Arguments

:: [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.

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

Like paths, but return only the element that matches the predicate.

leaves :: Tree.Tree a -> [a] Source #

Get all leaves. The list will never be null.

filter :: (a -> Bool) -> Tree.Tree a -> Maybe (Tree.Tree a) Source #

Filter out nodes that don't match.