data Tree = Empty | Node Integer Tree Tree tree1 = Node 2 (Node 3 (Node 1 Empty Empty) (Node 4 Empty Empty)) (Node 1 Empty (Node 5 Empty Empty)) {- 2 3 1 1 4 5-} sumMaxPath :: Tree -> Integer sumMaxPath Empty = 0 sumMaxPath (Node v l r) = v + max (sumMaxPath l) (sumMaxPath r) type Point = (Double, Double) dist :: Point -> Point -> Double dist (x1,y1) (x2,y2) = sqrt $ (x1-x2)^2 + (y1-y2)^2 maxDistance :: [Point] -> Double maxDistance points = maximum [ dist x y | x<-points, y<-points ] --distances x points = map (`dist` x) points --maxDistance points = maximum . concat $ map (\x -> (map (\y -> dist x y) points)) points count :: (Eq a) => a -> [a] -> Int count x l = length $ filter (==x) l remove :: (Eq a) => a -> [a] -> [a] remove x l = filter (/=x) l removeDuplicates :: (Eq a) => [a] -> [a] removeDuplicates [] = [] removeDuplicates (head:tail) = head : removeDuplicates (remove head tail) histogram :: (Eq a) => [a] -> [(a,Int)] histogram l = map (\x -> (x, count x l)) $ removeDuplicates l