I'm trying to learn Haskell and I stumbled upon a problem in my Haskell code. I have a function,
main = print (qSort [distance (3,4), distance (1,2), distance (2,2)])
distance :: (Floating a ) => (a,a) -> (a,a,a)
distance (x2 , y2) = (x2*x2 + y2*y2, x2, y2)
that calculates distance between (0,0) and given point. How can change it to something like:
main = print (qSort (distance [(3,4),(1,2),(2,2)]))
so that distance can take a whole array as input? Also, what way will be the best to try and get the points as input from the user? Looking at examples I can't really think of a way to get points. I've tried fiddling with square brackets, but I keep getting errors. Any help would be appreciated!