I am very new to Scala but I was wondering if anyone could help me.
I have the following data set in this format: Map[String, List[(Int, String, Float)]]
Data Sample:
Education Route (GU),1:University Of Strawberry:0.65f,2:City Of Cabbage College - Riverside Camp:1.4f,3:School of Sims:3.9f,4:Science Centre:0.7f,5:University of Grapes:2.4f,6:The Mushroom Library:1.9f,7: School Of Fruit:0.9f,8:Royal Conservatoire Of Melons:0.75f,9:GU:0.6f`
I am trying to get the average total distance and average number of stages of all routes - I have the following from a previous excercise :
def average(ls:List[Int]):Float = {
sum(ls)/length(ls)
}
println(average(list1))
I appreciate this is a more simplistic example but any help would be much appreciated. I also did think about the approach of adding the values up then dividing by the number of routes?