scala将两个数组合并成一个

scala> List(List("1","one"),List("2","two"))
res0: List[List[String]] = List(List(1, one), List(2, two))


scala> List(List("1","11","22","33"))

res1: List[List[String]] = List(List(1, 11, 22, 33))


scala> var ret = new HashMap[String,List[String]]


 scala> res1.foreach(x=>ret += x.head -> x)


scala> ret
res3: scala.collection.immutable.HashMap[String,List[String]] = Map(1 -> List(1,
 11, 22, 33))


scala> res0.map(x=> ret.getOrElse(x(0),x(0)::(1 to res1(0).length-1).map(x=>"--").toList))
res12: List[List[String]] = List(List(1, 11, 22, 33), List(2, --, --, --))



你可能感兴趣的:(scala)