我当前的系统可以找到整数列表的最后一个值,如下面的第一个文件所示。然后它将其显示为“当前”值。当我输入搜索并返回高于我搜索的结果的所有结果时,我需要能够找到所有“当前”值。列表保存为Map(String,List [Int])。< / p>
SK1, 9, 7, 2, 0, 7, 3, 7, 9, 1, 2, 8, 1, 9, 6, 5, 3, 2, 2, 7, 2, 8, 5, 4, 5, 1, 6, 5, 2, 4, 1
SK2, 0, 7, 6, 3, 3, 3, 1, 6, 9, 2, 9, 7, 8, 7, 3, 6, 3, 5, 5, 2, 9, 7, 3, 4, 6, 3, 4, 3, 4, 1
SK4, 2, 9, 5, 7, 0, 8, 6, 6, 7, 9, 0, 1, 3, 1, 6, 0, 0, 1, 3, 8, 5, 4, 0, 9, 7, 1, 4, 5, 2, 8
SK5, 2, 6, 8, 0, 3, 5, 5, 2, 5, 9, 4, 5, 3, 5, 7, 8, 8, 2, 5, 9, 3, 8, 6, 7, 8, 7, 4, 1, 2, 3
SK6, 2, 7, 5, 9, 1, 9, 8, 4, 1, 7, 3, 7, 0, 8, 4, 5, 9, 2, 4, 4, 8, 7, 9, 2, 2, 7, 9, 1, 6, 9
SK7, 6, 9, 5, 0, 0, 0, 0, 5, 8, 3, 8, 7, 1, 9, 6, 1, 5, 3, 4, 7, 9, 5, 5, 9, 1, 4, 4, 0, 2, 0
SK8, 2, 8, 8, 3, 1, 1, 0, 8, 5, 9, 0, 3, 1, 6, 8, 7, 9, 6, 7, 7, 0, 9, 5, 2, 5, 0, 2, 1, 8, 6
SK9, 7, 1, 8, 8, 4, 4, 2, 2, 7, 4, 0, 6, 9, 5, 5, 4, 9, 1, 8, 6, 3, 4, 8, 2, 7, 9, 7, 2, 6, 6
这就是我想要得到的;使用上面的数据文件,如果我搜索“SK5”,系统将返回;
数字高于SK5 - 3
SK4 - 8
SK6 - 9
SK8 - 6
SK9 - 6
这是我当前的代码,用于查找列表中的最后一个数字
//5 - Show Current Stock Level (W)
def handleFive(): Boolean = {
mnuShowSingleDataStock(currentStockLevel)
true
}
// Returns a single result, not a list
def mnuShowSingleDataStock(stock: (String) => (String,Int)) = {
print("Stock > ")
val data = stock(readLine)
println(s"${data._1}: ${data._2}")
}
//Show higher than stocks
def higherThan(stock: String): List[(String, List[Int])] = {
mapdata.toList.sortWith(_._2.last > _._2.last).takeWhile(row => row._2.last > mapdata.get(stock).map(_.last).getOrElse(0))
}
答案 0 :(得分:1)
根据最后一个值排序,然后在当前股票价值大于搜索到的股票价值时采取
//Pequeña base de datos local que guarda los médicos de Clínica Haskell (R)
Medico medico1 = new Medico("Maidana", "Juan", 123, new Fecha(3, 2, 1980), 1234);
Medico medico2 = new Medico("Miranda", "Jorge", 456, new Fecha(3, 2, 1980), 1234);
Medico medico3 = new Medico("Masmut", "Julian", 789, new Fecha(3, 2, 1980), 1234);
ObraSocial os1 = new ObraSocial(1, "Boreal");
ObraSocial os2 = new ObraSocial(2, "Asunt");
ObraSocial os3 = new ObraSocial(3, "Prensa");
Paciente paciente1 = new Paciente("Perez", "Juan", 123, new Fecha(3, 2, 1980), 1234, os1);
Paciente paciente2 = new Paciente("Patrón", "Jorge", 456, new Fecha(3, 2, 1980), 1234, os2);
Paciente paciente3 = new Paciente("Pons", "Julian", 789, new Fecha(3, 2, 1980), 1234, os3);
Medicamento medicamento1 = new Medicamento(1,"Bayaspirina", "Bayer");
Medicamento medicamento2 = new Medicamento(2,"Cafiaspirina", "Bayer");
Medicamento medicamento3 = new Medicamento(3,"Ibupirac 600", "Pfizer");