The exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following:
Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.
My answer is this:
import Data.List(sort) sumSquareLargest :: (Ord n, Floating n) => n -> n -> n -> n sumSquareLargest x y z = b ** 2 + c ** 2 where [a, b, c] = sort[x, y, z]
Am I doing unnecessary work here? How could I improve this answer, even if only stylistically-speaking?