I think you want
find :: Foldable t => (a -> Bool) -> t a -> Maybe a
Jian Fan wrote:
Hi,
There doesn't seem to be a function to search the tree so
I come up with following function:
searchTree :: (a -> Bool) -> TreeLoc a -> Maybe (TreeLoc a)
searchTree pred rootLoc =
if pred (getLabel root
I haven't tested it, but I think you're looking for something like this:
searchTree2 :: (a -> Bool) -> TreeLoc a -> Maybe (TreeLoc a)
searchTree2 pred rootLoc =
if pred (getLabel rootLoc)
then Just rootLoc
else firstChild rootLoc >>= siblings
where siblings loc = searchTree2 pred loc `
Hi,
There doesn't seem to be a function to search the tree so
I come up with following function:
searchTree :: (a -> Bool) -> TreeLoc a -> Maybe (TreeLoc a)
searchTree pred rootLoc =
if pred (getLabel rootLoc) then
Just rootLoc
else case firstChild rootLoc of
Just loc -> case sear