Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从向量中提取元素:
val vec = Vector[Vector[Int]];
我需要构建一个List[((x:Int,y:Int),elem:Int)]x 和 y 是坐标,elem 是元素>5 否则不插入的地方。
List[((x:Int,y:Int),elem:Int)]
这是你要找的吗?另外,如果这是家庭作业,请标记它。
val vec = Vector(Vector(1,2,3), Vector(4,5,6), Vector(7,8,9)) val res_v = for { (inner, i) <- vec.zipWithIndex (x, j) <- inner.zipWithIndex if x > 5 } yield ((i, j), x) res_v.toList