A bike race can be represented as a list of bike riders. Each rider is recorded with their ability class (High or Low), name, and the times in minutes that they finished in in each of their races, in the following types:
data Ability = High | Low data RiderResults = Rider Ability String [Int] type Championship = [RiderResults] How to solve totalTime :: RiderResults -> Int which returns the total time taken by that rider in all their races, including any penalty. High ability riders are penalised by having a time double their actual time (eg, pre-penalty total time 70mins becomes 140mins).
I've done something like
totalTime :: RiderResults -> Int totalTime (x:xs) = if x == Low then sum x*2 else x : totalTime xs but it is wrong. I have practice questions to solving types definition and data declarations in Haskell and this is one of them. Can someone please explain how to approach such questions?
totalTimefunction does.