Question: Haskell Coding Given a list of points, represented as integer pairs, return the centroid of the points. This will be a point where the x-coordinate
Haskell Coding Given a list of points, represented as integer pairs, return the centroid of the points. This will be a point where the x-coordinate is the average of all x-coordinates, and the y-coordinate is the average of all y-coordinates. You may assume that the list is non-empty. centroid :: [(Double, Double)] -> (Double, Double) Project1> centroid [(0,0)] (0.0,0.0) Project1> centroid [(0,0),(2,2)] (1.0,1.0) Project1> centroid [(0,2),(2,0),(4,4)] (2.0,2.0)
Given a list of characters, return a list where each character has been doubled, except spaces.
echons :: [Char] -> [Char]
Project1> echons "abc" "aabbcc" Project1> echons "d6 ?" "dd66 ??" Project1> echons "don't duplicate spaces" "ddoonn''tt dduupplliiccaattee ssppaacceess"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
