我想按各自的顺序添加scala元组,它应该按顺序添加到列表中
val d = (List.empty[String],List.empty[String],List.empty[String])
("1","2","3") :: d
("4","5","6") :: d
d应该提供类似(List("1","4"), List("2","5"),List("3","6"))
的输出
这样的事情?
implicit class TriplePrepend[A](t :(List[A],List[A],List[A])) {
def :: (x :(A,A,A)) = (x._1 :: t._1, x._2 :: t._2, x._3 :: t._3)
}
val d = (List.empty[String],List.empty[String],List.empty[String])
("1","2","3") :: ("4","5","6") :: d
//res0: (List(1, 4),List(2, 5),List(3, 6))