Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data FamilyTree = Void
- | Man (String, Int) (FamilyTree) (FamilyTree)
- | Female (String, Int) (FamilyTree) (FamilyTree)
- older :: Maybe (String, Int) -> Maybe (String,Int) -> Maybe (String,Int)
- older Nothing (Just (a)) = Just (a)
- older (Just (a)) Nothing = Just (a)
- older (Just (n1,y1)) (Just (n2,y2))
- | y1 <= y2 = Just (n1,y1)
- | otherwise = Just (n2,y2)
- {-
- -}
- oldestWoman :: FamilyTree -> Maybe (String,Int)
- oldestWoman Void = Nothing
- oldestWoman (Man (name, year) Void Void) = Nothing
- oldestWoman (Female (name, year) Void Void) = Just (name, year)
- oldestWoman (Man (name, year) left right) = older (oldestWoman left) (oldestWoman right)
- oldestWoman (Female (name, year) left right) = older (Just (name, year)) (older (oldestWoman left) (oldestWoman right))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement