I am working on a practice quiz and one of the questions makes you work with
data Person = MakePerson String Int Float
where String is the name, Int is the age, Float is the height. I must create a function that takes in a list of persons and returns the oldest person (know strict rules on if there are n oldest people, just pick one of them. I wrote this
oldest :: [Person] -> String
oldest [] = error("Empty list")
oldest ((MakePerson a b c):(MakePerson d e f):g)
| (b >= e) && (g == []) = a
| (b >= e) = oldest (MakePerson a b c):g
| (b < e) && (g == []) = d
| otherwise = oldest (MakePerson d e f):g
However, I am getting a parse error. I don't know how to create this function without having this double pattern since I need to always compare b and e and I have no other way of accessing their ages. How would I be able to write out this pattern for my parameters?
Parse Error in pattern: oldest oldest (MakePerson a b c):(MakePerson d e f):g
oldest. Hard to tell without looking at the full code though.