From c46e7b67e34a75acd59f40cf7c17aea67a6c6050 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 28 Jan 2019 23:19:29 -0800 Subject: [PATCH] Clean up HW2 a bit more. --- HW2.fedorind.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HW2.fedorind.hs b/HW2.fedorind.hs index b303f29..016f032 100644 --- a/HW2.fedorind.hs +++ b/HW2.fedorind.hs @@ -73,7 +73,7 @@ mapTree = fmap valueAt :: Path -> Tree a -> Maybe a valueAt _ End = Nothing valueAt [] (Node a _ _) = Just a -valueAt (x:xs) (Node a l r) = valueAt xs $ if x == L then l else r +valueAt (x:xs) (Node _ l r) = valueAt xs $ if x == L then l else r -- | Find a path to a node that contains the given value. -- @@ -94,10 +94,10 @@ valueAt (x:xs) (Node a l r) = valueAt xs $ if x == L then l else r -- pathTo :: Eq a => a -> Tree a -> Maybe Path -pathTo v End = Nothing +pathTo _ End = Nothing pathTo v (Node a l r) = orElse currentNode $ orElse (pathHelper v l L) $ pathHelper v r R where currentNode = if a == v then Just [] else Nothing - pathHelper v tree dir = fmap (dir:) (pathTo v tree) + pathHelper _ tree dir = fmap (dir:) (pathTo v tree) orElse m1 m2 = if isJust m1 then m1 else m2 isJust mx = mx /= Nothing