I am sorry if this question is very trivial, but I have struggled to find an answer to it for quite a time, that is why I decided to post it here.
I want to build a function which takes a list of binary tuples: [(Integer, Integer)] and outputs the maximum Integer from all the second Integers from all tuples. I wrote the following code:
maxSecond:: [(Integer,Integer)] -> Integer
maxSecond [(ks, as)] = aux (unzip [(ks, as)])
where aux ([ks],[as]) = maximum ([as])
But it only works if I input a list of only 1 tuple and outputs "Non-exhaustive patterns in function" error for a list of more than 2 tuples. My question is not as much how to actually solve the original problem, as why such an approach doesn't work in Haskell?
I have also wrote the following function:
aaa:: ([Integer], [Integer]) -> Integer
aaa ([as],[ms]) = 10
And apparently it is impossible to input a tuple of lists in Haskell (unless the lists are not made of 1 element). Is there any explanation to this?
Thank you!!