【发布时间】:2013-12-07 17:14:07
【问题描述】:
谁能解释一下下面的代码是做什么的? (炒作返回List[(Int,Int,Set[Int])])
def all(): List[(Int, Int, Set[Int])] =
{
list.zipWithIndex flatMap
{
case (row, r) =>
row.zipWithIndex.withFilter(_._1 == 0) map
{
case (col, c) => (r, c, hyp(r, c))
}
}
}
list 被定义为整数列表的列表。我知道 '==0' 是因为该方法需要访问 0 的元素,但我不明白 zipWithIndex 究竟做了什么。谢谢
【问题讨论】:
标签: list scala collections indexing