Clean up HW1 code.
This commit is contained in:
parent
ba781dad2d
commit
eb8754f62d
|
@ -10,7 +10,7 @@ data Tree
|
||||||
|
|
||||||
-- | An example binary tree, which will be used in tests.
|
-- | An example binary tree, which will be used in tests.
|
||||||
t1 :: Tree
|
t1 :: Tree
|
||||||
t1 = Node 1 (Node 2 (Node 3 (Leaf 4) (Leaf 5))
|
t1 = Node 1 (Node 2 (Node 3 (Leaf 4) (Lea 5))
|
||||||
(Leaf 6))
|
(Leaf 6))
|
||||||
(Node 7 (Leaf 8) (Leaf 9))
|
(Node 7 (Leaf 8) (Leaf 9))
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ treeFold f a (Node i l r) = f i $ treeFold f (treeFold f a r) l
|
||||||
-- 1
|
-- 1
|
||||||
--
|
--
|
||||||
leftmost :: Tree -> Int
|
leftmost :: Tree -> Int
|
||||||
leftmost = treeFoldr1 const
|
leftmost = treeFoldr1 (\a _ -> a)
|
||||||
|
|
||||||
-- | The integer at the right-most node of a binary tree.
|
-- | The integer at the right-most node of a binary tree.
|
||||||
--
|
--
|
||||||
|
@ -79,7 +79,7 @@ leftmost = treeFoldr1 const
|
||||||
-- 9
|
-- 9
|
||||||
--
|
--
|
||||||
rightmost :: Tree -> Int
|
rightmost :: Tree -> Int
|
||||||
rightmost = treeFoldl1 const
|
rightmost = treeFoldl1 (\a _ -> a)
|
||||||
|
|
||||||
-- | Get the maximum integer from a binary tree.
|
-- | Get the maximum integer from a binary tree.
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in New Issue
Block a user