Browse Source

Clean up HW1 code.

master
Danila Fedorin 2 years ago
parent
commit
eb8754f62d
  1. 6
      HW1.fedorind.hs

6
HW1.fedorind.hs

@ -10,7 +10,7 @@ data Tree
-- | An example binary tree, which will be used in tests.
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))
(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
--
leftmost :: Tree -> Int
leftmost = treeFoldr1 const
leftmost = treeFoldr1 (\a _ -> a)
-- | The integer at the right-most node of a binary tree.
--
@ -79,7 +79,7 @@ leftmost = treeFoldr1 const
-- 9
--
rightmost :: Tree -> Int
rightmost = treeFoldl1 const
rightmost = treeFoldl1 (\a _ -> a)
-- | Get the maximum integer from a binary tree.
--

Loading…
Cancel
Save